Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into streaming-test-data…
Browse files Browse the repository at this point in the history
…-alt
  • Loading branch information
torkelo committed Apr 24, 2019
2 parents 78abd2c + 2d6b33a commit bde8ec8
Show file tree
Hide file tree
Showing 68 changed files with 5,835 additions and 301 deletions.
1 change: 1 addition & 0 deletions conf/provisioning/dashboards/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ apiVersion: 1
# - name: 'default'
# orgId: 1
# folder: ''
# folderUid: ''
# type: file
# options:
# path: /var/lib/grafana/dashboards
1 change: 1 addition & 0 deletions devenv/dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: 1
providers:
- name: 'gdev dashboards'
folder: 'gdev dashboards'
folderUid: ''
type: file
updateIntervalSeconds: 60
options:
Expand Down
51 changes: 24 additions & 27 deletions docs/sources/administration/provisioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,19 @@ Checkout the [configuration](/installation/configuration) page for more informat
### Using Environment Variables

All options in the configuration file (listed below) can be overridden
using environment variables using the syntax:
It is possible to use environment variable interpolation in all 3 provisioning config types. Allowed syntax
is either `$ENV_VAR_NAME` or `${ENV_VAR_NAME}` and can be used only for values not for keys or bigger parts
of the configs. It is not available in the dashboards definition files just the dashboard provisioning
configuration.
Example:

```bash
GF_<SectionName>_<KeyName>
```

Where the section name is the text within the brackets. Everything
should be upper case and `.` should be replaced by `_`. For example, given these configuration settings:

```bash
# default section
instance_name = ${HOSTNAME}

[security]
admin_user = admin

[auth.google]
client_secret = 0ldS3cretKey
```

Overriding will be done like so:

```bash
export GF_DEFAULT_INSTANCE_NAME=my-instance
export GF_SECURITY_ADMIN_USER=true
export GF_AUTH_GOOGLE_CLIENT_SECRET=newS3cretKey
```yaml
datasources:
- name: Graphite
url: http://localhost:$PORT
user: $USER
secureJsonData:
password: $PASSWORD
```
<hr />
Expand Down Expand Up @@ -203,13 +189,24 @@ The dashboard provider config file looks somewhat like this:
apiVersion: 1
providers:
# <string> provider name
- name: 'default'
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string, required> name of the dashboard folder. Required
folder: ''
# <string> folder UID. will be automatically generated if not specified
folderUid: ''
# <string, required> provider type. Required
type: file
# <bool> disable dashboard deletion
disableDeletion: false
updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards
# <bool> enable dashboard editing
editable: true
# <int> how often Grafana will scan for changed dashboards
updateIntervalSeconds: 10
options:
# <string, required> path to dashboard files on disk. Required
path: /var/lib/grafana/dashboards
```

Expand Down
13 changes: 12 additions & 1 deletion docs/sources/features/datasources/cloudwatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ Name | Description
------------ | -------------
*Name* | The data source name. This is how you refer to the data source in panels & queries.
*Default* | Default data source means that it will be pre-selected for new panels.
*Credentials* profile name | Specify the name of the profile to use (if you use `~/.aws/credentials` file), leave blank for default.
*Default Region* | Used in query editor to set region (can be changed on per query basis)
*Custom Metrics namespace* | Specify the CloudWatch namespace of Custom metrics
*Auth Provider* | Specify the provider to get credentials.
*Credentials* profile name | Specify the name of the profile to use (if you use `~/.aws/credentials` file), leave blank for default.
*Assume Role Arn* | Specify the ARN of the role to assume

## Authentication
Expand Down Expand Up @@ -85,6 +86,16 @@ Here is a minimal policy example:
}
```

### AWS credentials
If Auth Provider is `Credentials file`, Grafana try to get credentials by following order.

- Environment variables. (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`)
- Hard-code credentials.
- Shared credentials file.
- IAM role for Amazon EC2.

Checkout AWS docs on [Configuring the AWS SDK for Go](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html)

### AWS credentials file

Create a file at `~/.aws/credentials`. That is the `HOME` path for user running grafana-server.
Expand Down
12 changes: 11 additions & 1 deletion packages/grafana-ui/.storybook/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ import { configure, addDecorator } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';
import { withTheme } from '../src/utils/storybook/withTheme';
import { withPaddedStory } from '../src/utils/storybook/withPaddedStory';

import 'jquery';
import '../../../public/vendor/flot/jquery.flot.js';
import '../../../public/vendor/flot/jquery.flot.selection';
import '../../../public/vendor/flot/jquery.flot.time';
import '../../../public/vendor/flot/jquery.flot.stack';
import '../../../public/vendor/flot/jquery.flot.pie';
import '../../../public/vendor/flot/jquery.flot.stackpercent';
import '../../../public/vendor/flot/jquery.flot.fillbelow';
import '../../../public/vendor/flot/jquery.flot.crosshair';
import '../../../public/vendor/flot/jquery.flot.dashes';
import '../../../public/vendor/flot/jquery.flot.gauge';
// @ts-ignore
import lightTheme from '../../../public/sass/grafana.light.scss';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react';
import isNil from 'lodash/isNil';
import classNames from 'classnames';
import Scrollbars from 'react-custom-scrollbars';
import { cx, css } from 'emotion';

interface Props {
className?: string;
Expand All @@ -10,8 +11,8 @@ interface Props {
autoHideDuration?: number;
autoHeightMax?: string;
hideTracksWhenNotNeeded?: boolean;
renderTrackHorizontal?: React.FunctionComponent<any>;
renderTrackVertical?: React.FunctionComponent<any>;
hideHorizontalTrack?: boolean;
hideVerticalTrack?: boolean;
scrollTop?: number;
setScrollTop: (event: any) => void;
autoHeightMin?: number | string;
Expand Down Expand Up @@ -79,8 +80,8 @@ export class CustomScrollbar extends Component<Props> {
autoHide,
autoHideTimeout,
hideTracksWhenNotNeeded,
renderTrackHorizontal,
renderTrackVertical,
hideHorizontalTrack,
hideVerticalTrack,
} = this.props;

return (
Expand All @@ -96,8 +97,28 @@ export class CustomScrollbar extends Component<Props> {
// Before these where set to inhert but that caused problems with cut of legends in firefox
autoHeightMax={autoHeightMax}
autoHeightMin={autoHeightMin}
renderTrackHorizontal={renderTrackHorizontal || (props => <div {...props} className="track-horizontal" />)}
renderTrackVertical={renderTrackVertical || (props => <div {...props} className="track-vertical" />)}
renderTrackHorizontal={props => (
<div
{...props}
className={cx(
css`
visibility: ${hideHorizontalTrack ? 'none' : 'visible'};
`,
'track-horizontal'
)}
/>
)}
renderTrackVertical={props => (
<div
{...props}
className={cx(
css`
visibility: ${hideVerticalTrack ? 'none' : 'visible'};
`,
'track-vertical'
)}
/>
)}
renderThumbHorizontal={props => <div {...props} className="thumb-horizontal" />}
renderThumbVertical={props => <div {...props} className="thumb-vertical" />}
renderView={props => <div {...props} className="view" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`CustomScrollbar renders correctly 1`] = `
</p>
</div>
<div
className="track-horizontal"
className="css-17l4171 track-horizontal"
style={
Object {
"display": "none",
Expand All @@ -58,7 +58,7 @@ exports[`CustomScrollbar renders correctly 1`] = `
/>
</div>
<div
className="track-vertical"
className="css-17l4171 track-vertical"
style={
Object {
"display": "none",
Expand Down
15 changes: 13 additions & 2 deletions packages/grafana-ui/src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Libraries
import $ from 'jquery';
import React, { PureComponent } from 'react';
import uniqBy from 'lodash/uniqBy';

// Types
import { TimeRange, GraphSeriesXY } from '../../types';

interface GraphProps {
export interface GraphProps {
series: GraphSeriesXY[];
timeRange: TimeRange; // NOTE: we should aim to make `time` a property of the axis, not force it for all graphs
showLines?: boolean;
Expand Down Expand Up @@ -46,7 +47,16 @@ export class Graph extends PureComponent<GraphProps> {
const ticks = width / 100;
const min = timeRange.from.valueOf();
const max = timeRange.to.valueOf();

const yaxes = uniqBy(
series.map(s => {
return {
show: true,
index: s.yAxis,
position: s.yAxis === 1 ? 'left' : 'right',
};
}),
yAxisConfig => yAxisConfig.index
);
const flotOptions = {
legend: {
show: false,
Expand Down Expand Up @@ -80,6 +90,7 @@ export class Graph extends PureComponent<GraphProps> {
ticks: ticks,
timeformat: timeFormat(ticks, min, max),
},
yaxes,
grid: {
minBorderMargin: 0,
markings: [],
Expand Down
105 changes: 105 additions & 0 deletions packages/grafana-ui/src/components/Graph/GraphLegend.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React from 'react';
import { storiesOf } from '@storybook/react';

import { GraphLegend } from './GraphLegend';
import { action } from '@storybook/addon-actions';
import { select, number } from '@storybook/addon-knobs';
import { withHorizontallyCenteredStory } from '../../utils/storybook/withCenteredStory';
import { generateLegendItems } from '../Legend/Legend.story';
import { LegendPlacement, LegendDisplayMode } from '../Legend/Legend';

const GraphLegendStories = storiesOf('Visualizations/Graph/GraphLegend', module);
GraphLegendStories.addDecorator(withHorizontallyCenteredStory);

const getStoriesKnobs = (isList = false) => {
const statsToDisplay = select(
'Stats to display',
{
none: [],
'single (min)': [{ text: '10ms', title: 'min', numeric: 10 }],
'multiple (min, max)': [
{ text: '10ms', title: 'min', numeric: 10 },
{ text: '100ms', title: 'max', numeric: 100 },
],
},
[]
);

const numberOfSeries = number('Number of series', 3);

const containerWidth = select(
'Container width',
{
Small: '200px',
Medium: '500px',
'Full width': '100%',
},
'100%'
);

const legendPlacement = select<LegendPlacement>(
'Legend placement',
{
under: 'under',
right: 'right',
},
'under'
);

return {
statsToDisplay,
numberOfSeries,
containerWidth,
legendPlacement,
};
};

GraphLegendStories.add('list', () => {
const { statsToDisplay, numberOfSeries, containerWidth, legendPlacement } = getStoriesKnobs(true);
return (
<div style={{ width: containerWidth }}>
<GraphLegend
displayMode={LegendDisplayMode.List}
items={generateLegendItems(numberOfSeries, statsToDisplay)}
onLabelClick={(item, event) => {
action('Series label clicked')(item, event);
}}
onSeriesColorChange={(label, color) => {
action('Series color changed')(label, color);
}}
onSeriesAxisToggle={(label, useRightYAxis) => {
action('Series axis toggle')(label, useRightYAxis);
}}
onToggleSort={sortBy => {
action('Toggle legend sort')(sortBy);
}}
placement={legendPlacement}
/>
</div>
);
});

GraphLegendStories.add('table', () => {
const { statsToDisplay, numberOfSeries, containerWidth, legendPlacement } = getStoriesKnobs();
return (
<div style={{ width: containerWidth }}>
<GraphLegend
displayMode={LegendDisplayMode.Table}
items={generateLegendItems(numberOfSeries, statsToDisplay)}
onLabelClick={item => {
action('Series label clicked')(item);
}}
onSeriesColorChange={(label, color) => {
action('Series color changed')(label, color);
}}
onSeriesAxisToggle={(label, useRightYAxis) => {
action('Series axis toggle')(label, useRightYAxis);
}}
onToggleSort={sortBy => {
action('Toggle legend sort')(sortBy);
}}
placement={legendPlacement}
/>
</div>
);
});
Loading

0 comments on commit bde8ec8

Please sign in to comment.