Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into stream-mixed-query
Browse files Browse the repository at this point in the history
* grafana/master:
  Docker: switch docker image to alpine base with phantomjs support (grafana#18468)
  Backend: Adds support for HTTP/2 (grafana#18358)
  Explore: Fixes error when switching from prometheus to loki data sources (grafana#18599)
  TimePicker: Set time to to 23:59:59 when setting To time using calendar (grafana#18595)
  Prometheus: Return labels in query results (grafana#18535)
  Docs: Update changelog and docs for annotation region change (grafana#18593)
  Refactor: move KeyValue and deprecation warning to @grafana/data (grafana#18582)
  Annotations: use a single row to represent a region (grafana#17673)
  Docs: Update upgrading guide (grafana#18547)
  Docs: Adds tests requirement to bugs checklist (grafana#18576)
  • Loading branch information
ryantxu committed Aug 16, 2019
2 parents a3adb0a + 302a1f0 commit 1df56e1
Show file tree
Hide file tree
Showing 45 changed files with 366 additions and 395 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 6.4.0 (unreleased)

### Breaking changes

* **Annotations**: There are some breaking changes in the annotations HTTP API for region annotations. Region
annotations are now represented using a single event instead of two seperate events. Check HTTP docs for more details.

# 6.3.3 (2019-08-15)

### Bug Fixes
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ To setup a local development environment we recommend reading [Building Grafana
#### Bug specific checks

- [ ] The pull request contains `Closes: #Issue` or `Fixes: #Issue` in pull request description.
- [ ] The Pull Request adds tests that replicate the fixed bug and helps avoid regressions.

### Frontend specific checks

Expand Down
33 changes: 24 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ COPY package.json package.json
RUN go run build.go build

# Node build container
FROM node:10.14.2
FROM node:10.14.2-alpine

# PhantomJS
RUN apk add --no-cache curl &&\
cd /tmp && curl -Ls https://github.com/dustinblackman/phantomized/releases/download/2.1.1/dockerized-phantomjs.tar.gz | tar xz &&\
cp -R lib lib64 / &&\
cp -R usr/lib/x86_64-linux-gnu /usr/lib &&\
cp -R usr/share /usr/share &&\
cp -R etc/fonts /etc &&\
curl -k -Ls https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 | tar -jxf - &&\
cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs

WORKDIR /usr/src/app/

Expand All @@ -33,7 +43,7 @@ ENV NODE_ENV production
RUN ./node_modules/.bin/grunt build

# Final container
FROM ubuntu:18.04
FROM alpine:3.10

LABEL maintainer="Grafana team <hello@grafana.com>"

Expand All @@ -50,16 +60,13 @@ ENV PATH=/usr/share/grafana/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bi

WORKDIR $GF_PATHS_HOME

RUN apt-get update && apt-get upgrade -y && \
apt-get install -qq -y libfontconfig1 ca-certificates && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache ca-certificates bash

COPY conf ./conf

RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
groupadd -r -g $GF_GID grafana && \
useradd -r -u $GF_UID -g grafana grafana && \
addgroup -S -g $GF_GID grafana && \
adduser -S -u $GF_UID -G grafana grafana && \
mkdir -p "$GF_PATHS_PROVISIONING/datasources" \
"$GF_PATHS_PROVISIONING/dashboards" \
"$GF_PATHS_PROVISIONING/notifiers" \
Expand All @@ -69,7 +76,15 @@ RUN mkdir -p "$GF_PATHS_HOME/.aws" && \
cp "$GF_PATHS_HOME/conf/sample.ini" "$GF_PATHS_CONFIG" && \
cp "$GF_PATHS_HOME/conf/ldap.toml" /etc/grafana/ldap.toml && \
chown -R grafana:grafana "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING" && \
chmod 777 -R "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"
chmod -R 777 "$GF_PATHS_DATA" "$GF_PATHS_HOME/.aws" "$GF_PATHS_LOGS" "$GF_PATHS_PLUGINS" "$GF_PATHS_PROVISIONING"

# PhantomJS
COPY --from=1 /tmp/lib /lib
COPY --from=1 /tmp/lib64 /lib64
COPY --from=1 /tmp/usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
COPY --from=1 /tmp/usr/share /usr/share
COPY --from=1 /tmp/etc/fonts /etc/fonts
COPY --from=1 /usr/local/bin/phantomjs /usr/local/bin

COPY --from=0 /go/src/github.com/grafana/grafana/bin/linux-amd64/grafana-server /go/src/github.com/grafana/grafana/bin/linux-amd64/grafana-cli ./bin/
COPY --from=1 /usr/src/app/public ./public
Expand Down
2 changes: 1 addition & 1 deletion conf/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provisioning = conf/provisioning

#################################### Server ##############################
[server]
# Protocol (http, https, socket)
# Protocol (http, https, h2, socket)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
Expand Down
2 changes: 1 addition & 1 deletion conf/sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#################################### Server ####################################
[server]
# Protocol (http, https, socket)
# Protocol (http, https, h2, socket)
;protocol = http

# The ip address to bind to, empty will bind to all interfaces
Expand Down
45 changes: 11 additions & 34 deletions docs/sources/http_api/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=
```


Query Parameters:

- `from`: epoch datetime in milliseconds. Optional.
Expand Down Expand Up @@ -56,9 +55,9 @@ Content-Type: application/json
"newState": "",
"prevState": "",
"time": 1507266395000,
"timeEnd": 1507266395000,
"text": "test",
"metric": "",
"regionId": 1123,
"type": "event",
"tags": [
"tag1",
Expand All @@ -78,7 +77,6 @@ Content-Type: application/json
"time": 1507265111000,
"text": "test",
"metric": "",
"regionId": 1123,
"type": "event",
"tags": [
"tag1",
Expand All @@ -89,9 +87,13 @@ Content-Type: application/json
]
```

> Starting in Grafana v6.4 regions annotations are now returned in one entity that now includes the timeEnd property.
## Create Annotation

Creates an annotation in the Grafana database. The `dashboardId` and `panelId` fields are optional. If they are not specified then a global annotation is created and can be queried in any dashboard that adds the Grafana annotations data source. When creating a region annotation the response will include both `id` and `endId`, if not only `id`.
Creates an annotation in the Grafana database. The `dashboardId` and `panelId` fields are optional.
If they are not specified then a global annotation is created and can be queried in any dashboard that adds
the Grafana annotations data source. When creating a region annotation include the timeEnd property.

`POST /api/annotations`

Expand All @@ -106,7 +108,6 @@ Content-Type: application/json
"dashboardId":468,
"panelId":1,
"time":1507037197339,
"isRegion":true,
"timeEnd":1507180805056,
"tags":["tag1","tag2"],
"text":"Annotation Description"
Expand All @@ -122,10 +123,13 @@ Content-Type: application/json
{
"message":"Annotation added",
"id": 1,
"endId": 2
}
```

> The response for this HTTP request is slightly different in versions prior to v6.4. In prior versions you would
also get an endId if you where creating a region. But in 6.4 regions are represented using a single event with time &
timeEnd properties.

## Create Annotation in Graphite format

Creates an annotation by using Graphite-compatible event format. The `when` and `data` fields are optional. If `when` is not specified then the current time will be used as annotation's timestamp. The `tags` field can also be in prior to Graphite `0.10.0`
Expand Down Expand Up @@ -176,7 +180,6 @@ Content-Type: application/json
{
"time":1507037197339,
"isRegion":true,
"timeEnd":1507180805056,
"text":"Annotation Description",
"tags":["tag3","tag4","tag5"]
Expand All @@ -201,7 +204,7 @@ Content-Type: application/json

Updates one or more properties of an annotation that matches the specified id.

This operation currently supports updating of the `text`, `tags`, `time` and `timeEnd` properties. It does not handle updating of the `isRegion` and `regionId` properties. To make an annotation regional or vice versa, consider using the [Update Annotation](#update-annotation) operation.
This operation currently supports updating of the `text`, `tags`, `time` and `timeEnd` properties.

**Example Request**:

Expand Down Expand Up @@ -253,29 +256,3 @@ Content-Type: application/json
"message":"Annotation deleted"
}
```

## Delete Annotation By RegionId

`DELETE /api/annotations/region/:id`

Deletes the annotation that matches the specified region id. A region is an annotation that covers a timerange and has a start and end time. In the Grafana database, this is a stored as two annotations connected by a region id.

**Example Request**:

```http
DELETE /api/annotations/region/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```

**Example Response**:

```http
HTTP/1.1 200
Content-Type: application/json
{
"message":"Annotation region deleted"
}
```
6 changes: 3 additions & 3 deletions docs/sources/installation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Another way is put a webserver like Nginx or Apache in front of Grafana and have

### protocol

`http`,`https` or `socket`
`http`,`https`,`h2` or `socket`

> **Note** Grafana versions earlier than 3.0 are vulnerable to [POODLE](https://en.wikipedia.org/wiki/POODLE). So we strongly recommend to upgrade to 3.x or use a reverse proxy for ssl termination.
Expand Down Expand Up @@ -179,11 +179,11 @@ reasons.

### cert_file

Path to the certificate file (if `protocol` is set to `https`).
Path to the certificate file (if `protocol` is set to `https` or `h2`).

### cert_key

Path to the certificate key file (if `protocol` is set to `https`).
Path to the certificate key file (if `protocol` is set to `https` or `h2`).

### router_logging

Expand Down
17 changes: 17 additions & 0 deletions docs/sources/installation/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ In order make this a reality Grafana upgrades are backward compatible and the up

Upgrading is generally always safe (between many minor and one major version) and dashboards and graphs will look the same. There can be minor breaking changes in some edge cases which are usually outlined in the [Release Notes](https://community.grafana.com/c/releases) and [Changelog](https://github.com/grafana/grafana/blob/master/CHANGELOG.md)

## Update plugins

After you have upgraded it is highly recommended that you update all your plugins as a new version of Grafana
can make older plugins stop working properly.

You can update all plugins using

```bash
grafana-cli plugins update-all
```

## Database Backup

Before upgrading it can be a good idea to backup your Grafana database. This will ensure that you can always rollback to your previous version. During startup, Grafana will automatically migrate the database schema (if there are changes or new tables). Sometimes this can cause issues if you later want to downgrade.
Expand Down Expand Up @@ -123,6 +134,12 @@ If you're using systemd and have a large amount of annotations consider temporar
If you have text panels with script tags they will no longer work due to a new setting that per default disallow unsanitized HTML.
Read more [here](/installation/configuration/#disable-sanitize-html) about this new setting.


## Upgrading to v6.4

One of the database migrations included in this release will merge multiple rows used to represent an annotation range into a single row. If you have a large number of region annotations the database migration may take a long time to complete. See [Upgrading to v5.2](#upgrading-to-v5-2) for tips on how to manage this process.


### Authentication and security

If your using Grafana's builtin, LDAP (without Auth Proxy) or OAuth authentication all users will be required to login upon the next visit after the upgrade.
Expand Down
6 changes: 5 additions & 1 deletion packages/grafana-data/src/types/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export type KeyValue<T = any> = { [s: string]: T };

export enum LoadingState {
NotStarted = 'NotStarted',
Loading = 'Loading',
Expand Down Expand Up @@ -70,7 +72,6 @@ export interface AnnotationEvent {
dashboardId?: number;
panelId?: number;
userId?: number;
regionId?: number;
login?: string;
email?: string;
avatarUrl?: string;
Expand All @@ -81,4 +82,7 @@ export interface AnnotationEvent {
text?: string;
type?: string;
tags?: string[];

// Currently used to merge annotations from alerts and dashboard
source?: any; // source.type === 'dashboard'
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyValue } from '../types/index';
import { KeyValue } from '../types';

// Avoid writing the warning message more than once every 10s
const history: KeyValue<number> = {};
Expand Down
1 change: 1 addition & 0 deletions packages/grafana-data/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './string';
export * from './registry';
export * from './markdown';
export * from './processDataFrame';
export * from './deprecationWarning';
export * from './csv';
export * from './fieldReducer';
export * from './logs';
Expand Down
3 changes: 2 additions & 1 deletion packages/grafana-data/src/utils/processDataFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import { isDateTime } from './moment_wrapper';
import { ArrayVector, SortedVector } from './vector';
import { DataFrameHelper } from './dataFrameHelper';
import { deprecationWarning } from './deprecationWarning';

function convertTableToDataFrame(table: TableData): DataFrame {
const fields = table.columns.map(c => {
Expand Down Expand Up @@ -224,7 +225,7 @@ export const toDataFrame = (data: any): DataFrame => {
for (let i = 0; i < rows.length; i++) {
v.appendRow(rows[i]);
}
// TODO: deprection warning
deprecationWarning('DataFrame', '.rows', 'columnar format');
return v;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deprecationWarning } from '../../utils/deprecationWarning';
import { deprecationWarning } from '@grafana/data';
import { ColorPickerProps } from './ColorPickerPopover';

export const warnAboutColorPickerPropsDeprecation = (componentName: string, props: ColorPickerProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class TimePickerPopover extends Component<Props, State> {
onToCalendarChanged = (value: DateTime) => {
value.set('h', 23);
value.set('m', 59);
value.set('s', 0);
value.set('s', 59);
this.setState({ to: value });
};

Expand Down
4 changes: 2 additions & 2 deletions packages/grafana-ui/src/types/app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentClass } from 'react';
import { NavModel } from '@grafana/data';
import { PluginMeta, PluginIncludeType, GrafanaPlugin, KeyValue } from './plugin';
import { NavModel, KeyValue } from '@grafana/data';
import { PluginMeta, PluginIncludeType, GrafanaPlugin } from './plugin';

export interface AppRootProps<T = KeyValue> {
meta: AppPluginMeta<T>;
Expand Down
3 changes: 1 addition & 2 deletions packages/grafana-ui/src/types/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentClass } from 'react';
import { KeyValue } from '@grafana/data';

export enum PluginState {
alpha = 'alpha', // Only included it `enable_alpha` is true
Expand All @@ -11,8 +12,6 @@ export enum PluginType {
app = 'app',
}

export type KeyValue<T = any> = { [s: string]: T };

export interface PluginMeta<T extends {} = KeyValue> {
id: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MappingType, ValueMapping, DisplayProcessor, DisplayValue } from '@grafana/data';

import { getDisplayProcessor, getColorFromThreshold, getDecimalsForValue } from './displayValue';
import { getDisplayProcessor, getColorFromThreshold, getDecimalsForValue } from './displayProcessor';

function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
processors.forEach(processor => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import { getValueFormat } from './valueFormats/valueFormats';
import { getColorFromHexRgbOrName } from './namedColorsPalette';

// Types
import { GrafanaTheme, GrafanaThemeType } from '../types';
import { GrafanaTheme, GrafanaThemeType } from '../types/index';

export interface DisplayValueOptions {
interface DisplayProcessorOptions {
field?: FieldConfig;

// Context
isUtc?: boolean;
theme?: GrafanaTheme; // Will pick 'dark' if not defined
}

export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProcessor {
export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayProcessor {
if (options && !_.isEmpty(options)) {
const field = options.field ? options.field : {};
const formatFunc = getValueFormat(field.unit || 'none');
Expand Down
2 changes: 1 addition & 1 deletion packages/grafana-ui/src/utils/fieldDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import toNumber from 'lodash/toNumber';
import toString from 'lodash/toString';

import { GrafanaTheme, InterpolateFunction, ScopedVars } from '../types/index';
import { getDisplayProcessor } from './displayValue';
import { getDisplayProcessor } from './displayProcessor';
import { getFlotPairs } from './flotPairs';

export interface FieldDisplayOptions {
Expand Down
Loading

0 comments on commit 1df56e1

Please sign in to comment.