Skip to content

Commit

Permalink
Merge remote-tracking branch 'grafana/master' into expose-lots
Browse files Browse the repository at this point in the history
* grafana/master:
  LDAP: remove unused function (grafana#17351)
  Enterprise: remove gofakeit dep (grafana#17344)
  Explore: Update time range before running queries (grafana#17349)
  Build(package.json): improve npm commands (grafana#17022)
  Chore: upgrade webpack analyser (grafana#17340)
  NewDataSourcePage: Add Grafana Cloud link (grafana#17324)
  CloudWatch: Avoid exception while accessing results (grafana#17283)
  Build: ignore absence of docker-compose (grafana#17331)
  Build(makefile): improve error handling (grafana#17281)
  adds auth example for the cli cherrypick task (grafana#17307)
  docs: remove my email from docs examples (grafana#17325)
  16365 change clashing variable names (grafana#17140)
  Frontend/SeriesData: Fix for convert SeriesData to Table format (grafana#17314)
  Frontend/utils: Import has only from lodash (grafana#17311)
  Frontend/utils: Add missing type  (grafana#17312)
  update v6.2-beta1 changelog with missing pr (grafana#17308)
  • Loading branch information
ryantxu committed May 29, 2019
2 parents b0889fe + a3092dc commit 429378c
Show file tree
Hide file tree
Showing 87 changed files with 177 additions and 2,273 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ repo on July 1st. Make sure you have switched to the new repo by then. The new r
* **Provisioning**: Add API endpoint to reload provisioning configs. [#16579](https://github.com/grafana/grafana/pull/16579), [@aocenas](https://github.com/aocenas)
* **Provisioning**: Do not allow deletion of provisioned dashboards. [#16211](https://github.com/grafana/grafana/pull/16211), [@aocenas](https://github.com/aocenas)
* **Provisioning**: Interpolate env vars in provisioning files. [#16499](https://github.com/grafana/grafana/pull/16499), [@aocenas](https://github.com/aocenas)
* **Provisioning**: Support FolderUid in Dashboard Provisioning Config. [#16559](https://github.com/grafana/grafana/pull/16559), [@swtch1](https://github.com/swtch1)
* **Security**: Add new setting allow_embedding. [#16853](https://github.com/grafana/grafana/pull/16853), [@marefr](https://github.com/marefr)
* **Security**: Store datasource passwords encrypted in secureJsonData. [#16175](https://github.com/grafana/grafana/pull/16175), [@aocenas](https://github.com/aocenas)
* **UX**: Improve Grafana usage for smaller screens. [#16783](https://github.com/grafana/grafana/pull/16783), [@torkelo](https://github.com/torkelo)
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,26 @@ revive: scripts/go/bin/revive

# create docker-compose file with provided sources and start them
# example: make devenv sources=postgres,openldap
ifeq ($(sources),)
devenv:
@printf 'You have to define sources for this command \nexample: make devenv sources=postgres,openldap\n'
else
devenv: devenv-down
$(eval targets := $(shell echo '$(sources)' | tr "," " "))

@cd devenv; \
./create_docker_compose.sh $(targets); \
./create_docker_compose.sh $(targets) || \
(rm -rf docker-compose.yaml; exit 1)

@cd devenv; \
docker-compose up -d
endif

# drop down the envs
devenv-down:
@cd devenv; docker-compose down;
@cd devenv; \
test -f docker-compose.yaml && \
docker-compose down || exit 0;

# TODO recheck the rules and leave only necessary exclusions
gosec: scripts/go/bin/gosec
Expand Down
6 changes: 4 additions & 2 deletions docs/sources/features/datasources/azuremonitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ To make writing queries easier there are several Grafana macros that can be used
`datetimeColumn ≥ datetime(2018-06-05T18:09:58.907Z) and`
`datetimeColumn ≤ datetime(2018-06-05T20:09:58.907Z)` where the from and to datetimes are from the Grafana time picker.

- `$__timeFrom()` - Returns the From datetime from the Grafana picker. Example: `datetime(2018-06-05T18:09:58.907Z)`.

- `$__timeTo()` - Returns the From datetime from the Grafana picker. Example: `datetime(2018-06-05T20:09:58.907Z)`.

- `$__escapeMulti($myVar)` - is to be used with multi-value template variables that contain illegal characters. If `$myVar` has the following two values as a string `'\\grafana-vm\Network(eth0)\Total','\\hello!'`, then it expands to: `@'\\grafana-vm\Network(eth0)\Total', @'\\hello!'`. If using single value variables there is no need for this macro, simply escape the variable inline instead - `@'\$myVar'`.

- `$__contains(colName, $myVar)` - is to be used with multi-value template variables. If `$myVar` has the value `'value1','value2'`, it expands to: `colName in ('value1','value2')`.
Expand All @@ -264,8 +268,6 @@ To make writing queries easier there are several Grafana macros that can be used

There are also some Grafana variables that can be used in Azure Log Analytics queries:

- `$__from` - Returns the From datetime from the Grafana picker. Example: `datetime(2018-06-05T18:09:58.907Z)`.
- `$__to` - Returns the From datetime from the Grafana picker. Example: `datetime(2018-06-05T20:09:58.907Z)`.
- `$__interval` - Grafana calculates the minimum time grain that can be used to group by time in queries. More details on how it works [here]({{< relref "reference/templating.md#interval-variables" >}}). It returns a time grain like `5m` or `1h` that can be used in the bin function. E.g. `summarize count() by bin(TimeGenerated, $__interval)`

### Azure Log Analytics Alerting
Expand Down
20 changes: 10 additions & 10 deletions docs/sources/http_api/alerting_notification_channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Content-Type: application/json
"sendReminder": false,
"disableResolveMessage": false,
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2018-04-23T14:44:09+02:00",
"updated": "2018-08-20T15:47:49+02:00"
Expand Down Expand Up @@ -93,7 +93,7 @@ Content-Type: application/json
"sendReminder": false,
"disableResolveMessage": false,
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2018-04-23T14:44:09+02:00",
"updated": "2018-08-20T15:47:49+02:00"
Expand Down Expand Up @@ -130,7 +130,7 @@ Content-Type: application/json
"sendReminder": false,
"disableResolveMessage": false,
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2018-04-23T14:44:09+02:00",
"updated": "2018-08-20T15:47:49+02:00"
Expand Down Expand Up @@ -158,7 +158,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
"isDefault": false,
"sendReminder": false,
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
}
}
```
Expand All @@ -177,7 +177,7 @@ Content-Type: application/json
"isDefault": false,
"sendReminder": false,
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2018-04-23T14:44:09+02:00",
"updated": "2018-08-20T15:47:49+02:00"
Expand Down Expand Up @@ -206,7 +206,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
"sendReminder": true,
"frequency": "15m",
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
}
}
```
Expand All @@ -226,7 +226,7 @@ Content-Type: application/json
"sendReminder": true,
"frequency": "15m",
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2017-01-01 12:34",
"updated": "2017-01-01 12:34"
Expand Down Expand Up @@ -256,7 +256,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
"sendReminder": true,
"frequency": "15m",
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
}
}
```
Expand All @@ -276,7 +276,7 @@ Content-Type: application/json
"sendReminder": true,
"frequency": "15m",
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
},
"created": "2017-01-01 12:34",
"updated": "2017-01-01 12:34"
Expand Down Expand Up @@ -353,7 +353,7 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"type": "email",
"settings": {
"addresses": "carl@grafana.com;dev@grafana.com"
"addresses": "dev@grafana.com"
}
}
```
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ require (
github.com/aws/aws-sdk-go v1.18.5
github.com/benbjohnson/clock v0.0.0-20161215174838-7dc76406b6d3
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737
github.com/brianvoe/gofakeit v3.17.0+incompatible
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/codegangsta/cli v1.20.0
github.com/davecgh/go-spew v1.1.1
github.com/denisenkom/go-mssqldb v0.0.0-20190315220205-a8ed825ac853
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect
github.com/facebookgo/inject v0.0.0-20180706035515-f23751cae28b
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLM
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737 h1:rRISKWyXfVxvoa702s91Zl5oREZTrR3yv+tXrrX7G/g=
github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
github.com/brianvoe/gofakeit v3.17.0+incompatible h1:C1+30+c0GtjgGDtRC+iePZeP1WMiwsWCELNJhmc7aIc=
github.com/brianvoe/gofakeit v3.17.0+incompatible/go.mod h1:kfwdRA90vvNhPutZWfH7WPaDzUjz+CZFqG+rPkOjGOc=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w=
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"tslint-react": "3.6.0",
"typescript": "3.4.1",
"webpack": "4.29.6",
"webpack-bundle-analyzer": "3.1.0",
"webpack-bundle-analyzer": "3.3.2",
"webpack-cleanup-plugin": "0.5.1",
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.2.1",
Expand All @@ -140,9 +140,9 @@
},
"scripts": {
"dev": "webpack --progress --colors --mode development --config scripts/webpack/webpack.dev.js",
"start": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts core:start --watchTheme",
"start:hot": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts core:start --hot --watchTheme",
"start:ignoreTheme": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts core:start --hot",
"start": "npm run cli -- core:start --watchTheme",
"start:hot": "npm run cli -- core:start --hot --watchTheme",
"start:ignoreTheme": "npm run cli -- core:start --hot",
"watch": "yarn start -d watch,start core:start --watchTheme ",
"build": "grunt build",
"test": "grunt test",
Expand All @@ -156,13 +156,13 @@
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts",
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"",
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss}\" --write",
"cli": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts",
"gui:tslint": "tslint -c ./packages/grafana-ui/tslint.json --project ./packages/grafana-ui/tsconfig.json",
"gui:build": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts gui:build",
"gui:releasePrepare": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts gui:release",
"gui:build": "npm run cli -- gui:build",
"gui:releasePrepare": "npm run cli -- gui:release",
"gui:publish": "cd packages/grafana-ui/dist && npm publish --access public",
"gui:release": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts gui:release -p --createVersionCommit",
"precommit": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts precommit",
"cli": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/index.ts"
"gui:release": "npm run cli -- gui:release -p --createVersionCommit",
"precommit": "npm run cli -- precommit"
},
"husky": {
"hooks": {
Expand Down
1 change: 0 additions & 1 deletion pkg/extensions/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package extensions

import (
_ "github.com/brianvoe/gofakeit"
_ "github.com/gobwas/glob"
_ "github.com/robfig/cron"
_ "gopkg.in/square/go-jose.v2"
Expand Down
16 changes: 5 additions & 11 deletions pkg/services/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type IConnection interface {
type IServer interface {
Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error)
Users([]string) ([]*models.ExternalUserInfo, error)
ExtractGrafanaUser(*UserInfo) (*models.ExternalUserInfo, error)
InitialBind(string, string) error
Dial() error
Close()
Expand Down Expand Up @@ -148,6 +147,11 @@ func (server *Server) Login(query *models.LoginUserQuery) (

// Check if a second user bind is needed
user := users[0]

if err := server.validateGrafanaUser(user); err != nil {
return nil, err
}

if server.requireSecondBind {
err = server.secondBind(user, query.Password)
if err != nil {
Expand Down Expand Up @@ -188,16 +192,6 @@ func (server *Server) Users(logins []string) (
return serializedUsers, nil
}

// ExtractGrafanaUser extracts external user info from LDAP user
func (server *Server) ExtractGrafanaUser(user *UserInfo) (*models.ExternalUserInfo, error) {
result := server.buildGrafanaUser(user)
if err := server.validateGrafanaUser(result); err != nil {
return nil, err
}

return result, nil
}

// validateGrafanaUser validates user access.
// If there are no ldap group mappings access is true
// otherwise a single group must match
Expand Down
6 changes: 3 additions & 3 deletions public/app/core/utils/kbn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from 'lodash';
import { has } from 'lodash';
import { getValueFormat, getValueFormatterIndex, getValueFormats, stringToJsRegex } from '@grafana/ui';
import deprecationWarning from '@grafana/ui/src/utils/deprecationWarning';

Expand Down Expand Up @@ -133,7 +133,7 @@ kbn.secondsToHms = seconds => {
};

kbn.secondsToHhmmss = seconds => {
const strings = [];
const strings: string[] = [];
const numhours = Math.floor(seconds / 3600);
const numminutes = Math.floor((seconds % 3600) / 60);
const numseconds = Math.floor((seconds % 3600) % 60);
Expand Down Expand Up @@ -193,7 +193,7 @@ kbn.calculateInterval = (range, resolution, lowLimitInterval) => {

kbn.describe_interval = str => {
const matches = str.match(kbn.interval_regex);
if (!matches || !_.has(kbn.intervals_in_seconds, matches[2])) {
if (!matches || !has(kbn.intervals_in_seconds, matches[2])) {
throw new Error('Invalid interval string, expecting a number followed by one of "Mwdhmsy"');
} else {
return {
Expand Down
44 changes: 39 additions & 5 deletions public/app/features/datasources/NewDataSourcePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StoreState } from 'app/types';
import { addDataSource, loadDataSourceTypes, setDataSourceTypeSearchQuery } from './state/actions';
import { getDataSourceTypes } from './state/selectors';
import { FilterInput } from 'app/core/components/FilterInput/FilterInput';
import { NavModel, DataSourcePluginMeta, List } from '@grafana/ui';
import { NavModel, DataSourcePluginMeta, List, PluginType } from '@grafana/ui';

export interface Props {
navModel: NavModel;
Expand Down Expand Up @@ -43,6 +43,7 @@ class NewDataSourcePage extends PureComponent<Props> {
loki: 90,
mysql: 80,
postgres: 79,
gcloud: -1,
};

componentDidMount() {
Expand Down Expand Up @@ -114,6 +115,8 @@ class NewDataSourcePage extends PureComponent<Props> {
{} as DataSourceCategories
);

categories['cloud'].push(getGrafanaCloudPhantomPlugin());

return (
<>
{this.categoryInfoList.map(category => (
Expand Down Expand Up @@ -174,7 +177,9 @@ interface DataSourceTypeCardProps {
}

const DataSourceTypeCard: FC<DataSourceTypeCardProps> = props => {
const { plugin, onClick, onLearnMoreClick } = props;
const { plugin, onLearnMoreClick } = props;
const canSelect = plugin.id !== 'gcloud';
const onClick = canSelect ? props.onClick : () => {};

// find first plugin info link
const learnMoreLink = plugin.info.links && plugin.info.links.length > 0 ? plugin.info.links[0].url : null;
Expand All @@ -188,16 +193,45 @@ const DataSourceTypeCard: FC<DataSourceTypeCardProps> = props => {
</div>
<div className="add-data-source-item-actions">
{learnMoreLink && (
<a className="btn btn-inverse" href={learnMoreLink} target="_blank" onClick={onLearnMoreClick}>
Learn more
<a
className="btn btn-inverse"
href={`${learnMoreLink}?utm_source=grafana_add_ds`}
target="_blank"
onClick={onLearnMoreClick}
>
Learn more <i className="fa fa-external-link add-datasource-item-actions__btn-icon" />
</a>
)}
<button className="btn btn-primary">Select</button>
{canSelect && <button className="btn btn-primary">Select</button>}
</div>
</div>
);
};

function getGrafanaCloudPhantomPlugin(): DataSourcePluginMeta {
return {
id: 'gcloud',
name: 'Grafana Cloud',
type: PluginType.datasource,
module: '',
baseUrl: '',
info: {
description: 'Hosted Graphite, Prometheus and Loki',
logos: { small: 'public/img/grafana_icon.svg', large: 'asd' },
author: { name: 'Grafana Labs' },
links: [
{
url: 'https://grafana.com/cloud',
name: 'Learn more',
},
],
screenshots: [],
updated: '2019-05-10',
version: '1.0.0',
},
};
}

export function getNavModel(): NavModel {
const main = {
icon: 'gicon gicon-add-datasources',
Expand Down
1 change: 1 addition & 0 deletions public/app/features/explore/state/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export interface LoadExploreDataSourcesPayload {

export interface RunQueriesPayload {
exploreId: ExploreId;
range: TimeRange;
}

export interface ResetQueryErrorPayload {
Expand Down
6 changes: 5 additions & 1 deletion public/app/features/explore/state/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false, replaceU
datasourceError,
containerWidth,
mode,
range,
} = getState().explore[exploreId];

if (datasourceError) {
Expand All @@ -538,7 +539,10 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false, replaceU
// but we're using the datasource interval limit for now
const interval = datasourceInstance.interval;

dispatch(runQueriesAction({ exploreId }));
const timeZone = getTimeZone(getState().user);
const updatedRange = getTimeRange(timeZone, range.raw);

dispatch(runQueriesAction({ exploreId, range: updatedRange }));
// Keep table queries first since they need to return quickly
if ((ignoreUIState || showingTable) && mode === ExploreMode.Metrics) {
dispatch(
Expand Down
Loading

0 comments on commit 429378c

Please sign in to comment.