Commit 69d0e824 by Torkel Ödegaard

Merge branch 'master' into apps

Conflicts:
	pkg/services/sqlstore/migrations/migrations.go
parents aa32459b 8a2af9b8
...@@ -7,12 +7,16 @@ ...@@ -7,12 +7,16 @@
### Enhancements ### ### Enhancements ###
* **Sessions**: Support for memcached as session storage, closes [#3458](https://github.com/grafana/grafana/pull/3458) * **Sessions**: Support for memcached as session storage, closes [#3458](https://github.com/grafana/grafana/pull/3458)
* **mysql**: Grafana now supports ssl for mysql, closes [#3584](https://github.com/grafana/grafana/pull/3584)
# 2.6.1 (unrelased, 2.6.x branch) # 2.6.1 (unrelased, 2.6.x branch)
### New Features ### New Features
* **Elasticsearch**: Support for derivative unit option, closes [#3512](https://github.com/grafana/grafana/issues/3512) * **Elasticsearch**: Support for derivative unit option, closes [#3512](https://github.com/grafana/grafana/issues/3512)
### Bug fixes
* **Graph Panel**: Fixed typehead when adding series style override, closes [#3554](https://github.com/grafana/grafana/issues/3554)
# 2.6.0 (2015-12-14) # 2.6.0 (2015-12-14)
### New Features ### New Features
......
Copyright 2014-2015 Torkel Ödegaard, Raintank Inc. Copyright 2014-2016 Torkel Ödegaard, Raintank Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you Licensed under the Apache License, Version 2.0 (the "License"); you
may not use this file except in compliance with the License. You may may not use this file except in compliance with the License. You may
......
...@@ -63,9 +63,15 @@ name = grafana ...@@ -63,9 +63,15 @@ name = grafana
user = root user = root
password = password =
# For "postgres" only, either "disable", "require" or "verify-full" # For "postgres", use either "disable", "require" or "verify-full"
# For "mysql", use either "true", "false", or "skip-verify".
ssl_mode = disable ssl_mode = disable
ca_cert_path =
client_key_path =
client_cert_path =
server_cert_name =
# For "sqlite3" only, path relative to data_path setting # For "sqlite3" only, path relative to data_path setting
path = grafana.db path = grafana.db
...@@ -79,7 +85,9 @@ provider = file ...@@ -79,7 +85,9 @@ provider = file
# file: session dir path, is relative to grafana data_path # file: session dir path, is relative to grafana data_path
# redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana` # redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana`
# postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable # postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
# mysql: go-sql-driver/mysql dsn config string, e.g. `user:password@tcp(127.0.0.1:3306)/database_name` # mysql: go-sql-driver/mysql dsn config string, examples:
# `user:password@tcp(127.0.0.1:3306)/database_name`
# `user:password@unix(/var/run/mysqld/mysqld.sock)/database_name`
# memcache: 127.0.0.1:11211 # memcache: 127.0.0.1:11211
......
...@@ -77,6 +77,11 @@ The Elasticsearch datasource supports two types of queries you can use to fill t ...@@ -77,6 +77,11 @@ The Elasticsearch datasource supports two types of queries you can use to fill t
{"find": "fields", "type": "string"} {"find": "fields", "type": "string"}
``` ```
### Fields filtered by type, with filter
```json
{"find": "fields", "type": "string", "query": <lucene query>}
```
### Multi format / All format ### Multi format / All format
Use lucene format. Use lucene format.
......
...@@ -156,7 +156,24 @@ The database user's password (not applicable for `sqlite3`). ...@@ -156,7 +156,24 @@ The database user's password (not applicable for `sqlite3`).
### ssl_mode ### ssl_mode
For `postgres` only, either `disable`, `require` or `verify-full`. For Postgres, use either `disable`, `require` or `verify-full`.
For MySQL, use either `true`, `false`, or `skip-verify`.
### ca_cert_path
(MySQL only) The path to the CA certificate to use. On many linux systems, certs can be found in `/etc/ssl/certs`.
### client_key_path
(MySQL only) The path to the client key. Only if server requires client authentication.
### client_cert_path
(MySQL only) The path to the client cert. Only if server requires client authentication.
### server_cert_name
(MySQL only) The common name field of the certificate used by the `mysql` server. Not necessary if `ssl_mode` is set to `skip-verify`.
<hr /> <hr />
......
...@@ -79,6 +79,9 @@ func scan(pluginDir string) error { ...@@ -79,6 +79,9 @@ func scan(pluginDir string) error {
} }
if err := util.Walk(pluginDir, true, true, scanner.walker); err != nil { if err := util.Walk(pluginDir, true, true, scanner.walker); err != nil {
if pluginDir != "data/plugins" {
log.Warn("Could not scan dir \"%v\" error: %s", pluginDir, err)
}
return err return err
} }
......
...@@ -19,6 +19,7 @@ func AddMigrations(mg *Migrator) { ...@@ -19,6 +19,7 @@ func AddMigrations(mg *Migrator) {
addDashboardSnapshotMigrations(mg) addDashboardSnapshotMigrations(mg)
addQuotaMigration(mg) addQuotaMigration(mg)
addAppPluginMigration(mg) addAppPluginMigration(mg)
addSessionMigration(mg)
} }
func addMigrationLogMigrations(mg *Migrator) { func addMigrationLogMigrations(mg *Migrator) {
......
package migrations
import . "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
func addSessionMigration(mg *Migrator) {
var sessionV1 = Table{
Name: "session",
Columns: []*Column{
{Name: "key", Type: DB_Char, IsPrimaryKey: true, Length: 16},
{Name: "data", Type: DB_Blob},
{Name: "expiry", Type: DB_Integer, Length: 255, Nullable: false},
},
}
mg.AddMigration("create session table", NewAddTableMigration(sessionV1))
}
...@@ -14,12 +14,21 @@ import ( ...@@ -14,12 +14,21 @@ import (
"github.com/grafana/grafana/pkg/services/sqlstore/migrator" "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
"github.com/go-sql-driver/mysql"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm" "github.com/go-xorm/xorm"
_ "github.com/lib/pq" _ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
) )
type MySQLConfig struct {
SslMode string
CaCertPath string
ClientKeyPath string
ClientCertPath string
ServerCertName string
}
var ( var (
x *xorm.Engine x *xorm.Engine
dialect migrator.Dialect dialect migrator.Dialect
...@@ -30,6 +39,8 @@ var ( ...@@ -30,6 +39,8 @@ var (
Type, Host, Name, User, Pwd, Path, SslMode string Type, Host, Name, User, Pwd, Path, SslMode string
} }
mysqlConfig MySQLConfig
UseSQLite3 bool UseSQLite3 bool
) )
...@@ -113,8 +124,22 @@ func getEngine() (*xorm.Engine, error) { ...@@ -113,8 +124,22 @@ func getEngine() (*xorm.Engine, error) {
cnnstr := "" cnnstr := ""
switch DbCfg.Type { switch DbCfg.Type {
case "mysql": case "mysql":
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8", protocol := "tcp"
DbCfg.User, DbCfg.Pwd, DbCfg.Host, DbCfg.Name) if strings.HasPrefix(DbCfg.Host, "/") {
protocol = "unix"
}
cnnstr = fmt.Sprintf("%s:%s@%s(%s)/%s?charset=utf8",
DbCfg.User, DbCfg.Pwd, protocol, DbCfg.Host, DbCfg.Name)
if mysqlConfig.SslMode == "true" || mysqlConfig.SslMode == "skip-verify" {
tlsCert, err := makeCert("custom", mysqlConfig)
if err != nil {
return nil, err
}
mysql.RegisterTLSConfig("custom", tlsCert)
cnnstr += "&tls=custom"
}
case "postgres": case "postgres":
var host, port = "127.0.0.1", "5432" var host, port = "127.0.0.1", "5432"
fields := strings.Split(DbCfg.Host, ":") fields := strings.Split(DbCfg.Host, ":")
...@@ -156,4 +181,12 @@ func LoadConfig() { ...@@ -156,4 +181,12 @@ func LoadConfig() {
} }
DbCfg.SslMode = sec.Key("ssl_mode").String() DbCfg.SslMode = sec.Key("ssl_mode").String()
DbCfg.Path = sec.Key("path").MustString("data/grafana.db") DbCfg.Path = sec.Key("path").MustString("data/grafana.db")
if DbCfg.Type == "mysql" {
mysqlConfig.SslMode = DbCfg.SslMode
mysqlConfig.CaCertPath = sec.Key("ca_cert_path").String()
mysqlConfig.ClientKeyPath = sec.Key("client_key_path").String()
mysqlConfig.ClientCertPath = sec.Key("client_cert_path").String()
mysqlConfig.ServerCertName = sec.Key("server_cert_name").String()
}
} }
package sqlstore
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
)
func makeCert(tlsPoolName string, config MySQLConfig) (*tls.Config, error) {
rootCertPool := x509.NewCertPool()
pem, err := ioutil.ReadFile(config.CaCertPath)
if err != nil {
return nil, fmt.Errorf("Could not read DB CA Cert path: %v", config.CaCertPath)
}
if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
return nil, err
}
clientCert := make([]tls.Certificate, 0, 1)
if config.ClientCertPath != "" && config.ClientKeyPath != "" {
certs, err := tls.LoadX509KeyPair(config.ClientCertPath, config.ClientKeyPath)
if err != nil {
return nil, err
}
clientCert = append(clientCert, certs)
}
tlsConfig := &tls.Config{
RootCAs: rootCertPool,
Certificates: clientCert,
}
tlsConfig.ServerName = config.ServerCertName
if config.SslMode == "skip-verify" {
tlsConfig.InsecureSkipVerify = true
}
// Return more meaningful error before it is too late
if config.ServerCertName == "" && !tlsConfig.InsecureSkipVerify {
return nil, fmt.Errorf("server_cert_name is missing. Consider using ssl_mode = skip-verify.")
}
return tlsConfig, nil
}
...@@ -74,11 +74,10 @@ function (_, $, coreModule) { ...@@ -74,11 +74,10 @@ function (_, $, coreModule) {
updater: function (value) { updater: function (value) {
var result = {}; var result = {};
_.each($scope.menuItems, function(menuItem) { _.each($scope.menuItems, function(menuItem) {
result.$item = menuItem;
_.each(menuItem.submenu, function(submenuItem) { _.each(menuItem.submenu, function(submenuItem) {
if (value === (menuItem.text + ' ' + submenuItem.text)) { if (value === (menuItem.text + ' ' + submenuItem.text)) {
result.$subItem = submenuItem; result.$subItem = submenuItem;
result.$item = menuItem;
} }
}); });
}); });
......
define([ ///<reference path="../../../headers/common.d.ts" />
"angular",
"lodash",
"moment",
],function (angular, _, moment) {
'use strict';
angular. import _ from 'lodash';
module("grafana.directives"). import angular from 'angular';
directive('inputDatetime', function () { import moment from 'moment';
return {
restrict: 'A',
require: 'ngModel',
link: function ($scope, $elem, attrs, ngModel) {
var format = 'YYYY-MM-DD HH:mm:ss';
var fromUser = function (text) { export function inputDateDirective() {
if (text.indexOf('now') !== -1) { return {
return text; restrict: 'A',
} require: 'ngModel',
var parsed; link: function ($scope, $elem, attrs, ngModel) {
if ($scope.ctrl.isUtc) { var format = 'YYYY-MM-DD HH:mm:ss';
parsed = moment.utc(text, format);
} else {
parsed = moment(text, format);
}
return parsed.isValid() ? parsed : undefined; var fromUser = function (text) {
}; if (text.indexOf('now') !== -1) {
return text;
}
var parsed;
if ($scope.ctrl.isUtc) {
parsed = moment.utc(text, format);
} else {
parsed = moment(text, format);
}
var toUser = function (currentValue) { return parsed.isValid() ? parsed : undefined;
if (moment.isMoment(currentValue)) { };
return currentValue.format(format);
} else { var toUser = function (currentValue) {
return currentValue; if (moment.isMoment(currentValue)) {
} return currentValue.format(format);
}; } else {
return currentValue;
}
};
ngModel.$parsers.push(fromUser);
ngModel.$formatters.push(toUser);
}
};
}
ngModel.$parsers.push(fromUser);
ngModel.$formatters.push(toUser);
}
};
});
});
///<reference path="../../../headers/common.d.ts" /> ///<reference path="../../../headers/common.d.ts" />
///<amd-dependency path="./input_date" name="inputDate" />
import _ from 'lodash'; import _ from 'lodash';
import kbn from 'app/core/utils/kbn'; import kbn from 'app/core/utils/kbn';
...@@ -9,8 +8,6 @@ import moment from 'moment'; ...@@ -9,8 +8,6 @@ import moment from 'moment';
import * as dateMath from 'app/core/utils/datemath'; import * as dateMath from 'app/core/utils/datemath';
import * as rangeUtil from 'app/core/utils/rangeutil'; import * as rangeUtil from 'app/core/utils/rangeutil';
declare var inputDate: any;
export class TimePickerCtrl { export class TimePickerCtrl {
static tooltipFormat = 'MMM D, YYYY HH:mm:ss'; static tooltipFormat = 'MMM D, YYYY HH:mm:ss';
...@@ -179,3 +176,6 @@ export function timePickerDirective() { ...@@ -179,3 +176,6 @@ export function timePickerDirective() {
angular.module('grafana.directives').directive('gfTimePickerSettings', settingsDirective); angular.module('grafana.directives').directive('gfTimePickerSettings', settingsDirective);
angular.module('grafana.directives').directive('gfTimePicker', timePickerDirective); angular.module('grafana.directives').directive('gfTimePicker', timePickerDirective);
import {inputDateDirective} from './input_date';
angular.module("grafana.directives").directive('inputDatetime', inputDateDirective);
...@@ -56,7 +56,7 @@ export class GrafanaApp { ...@@ -56,7 +56,7 @@ export class GrafanaApp {
'ang-drag-drop', 'ang-drag-drop',
'grafana', 'grafana',
'pasvaz.bindonce', 'pasvaz.bindonce',
'ui.bootstrap.tabs', 'ui.bootstrap',
'ui.bootstrap.tpls', 'ui.bootstrap.tpls',
]; ];
......
...@@ -7,7 +7,7 @@ function (angular, _) { ...@@ -7,7 +7,7 @@ function (angular, _) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('PrometheusQueryCtrl', function($scope) { module.controller('PrometheusQueryCtrl', function($scope, templateSrv) {
$scope.init = function() { $scope.init = function() {
var target = $scope.target; var target = $scope.target;
...@@ -46,9 +46,9 @@ function (angular, _) { ...@@ -46,9 +46,9 @@ function (angular, _) {
$scope.linkToPrometheus = function() { $scope.linkToPrometheus = function() {
var range = Math.ceil(($scope.range.to.valueOf() - $scope.range.from.valueOf()) / 1000); var range = Math.ceil(($scope.range.to.valueOf() - $scope.range.from.valueOf()) / 1000);
var endTime = $scope.range.to.utc().format('YYYY-MM-DD HH:MM'); var endTime = $scope.range.to.utc().format('YYYY-MM-DD HH:mm');
var expr = { var expr = {
expr: $scope.target.expr, expr: templateSrv.replace($scope.target.expr, $scope.panel.scopedVars),
range_input: range + 's', range_input: range + 's',
end_input: endTime, end_input: endTime,
step_input: '', step_input: '',
......
...@@ -181,6 +181,13 @@ ...@@ -181,6 +181,13 @@
<li class="tight-form-item"> <li class="tight-form-item">
<editor-checkbox text="Right side" model="panel.legend.rightSide" change="render()"></editor-checkbox> <editor-checkbox text="Right side" model="panel.legend.rightSide" change="render()"></editor-checkbox>
</li> </li>
<li ng-if="panel.legend.rightSide" class="tight-form-item">
Side width
</li>
<li ng-if="panel.legend.rightSide" style="width: 105px">
<input type="number" class="input-small tight-form-input" placeholder="250" bs-tooltip="'Set a min-width for the legend side table/block'" data-placement="right"
ng-model="panel.legend.sideWidth" ng-change="render()" ng-model-onblur>
</li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -79,9 +79,9 @@ function ($) { ...@@ -79,9 +79,9 @@ function ($) {
// Stacked series can increase its length on each new stacked serie if null points found, // Stacked series can increase its length on each new stacked serie if null points found,
// to speed the index search we begin always on the last found hoverIndex. // to speed the index search we begin always on the last found hoverIndex.
var newhoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex); var newhoverIndex = this.findHoverIndexFromDataPoints(pos.x, series, hoverIndex);
results.push({ value: value, hoverIndex: newhoverIndex}); results.push({ value: value, hoverIndex: newhoverIndex, color: series.color, label: series.label });
} else { } else {
results.push({ value: value, hoverIndex: hoverIndex}); results.push({ value: value, hoverIndex: hoverIndex, color: series.color, label: series.label });
} }
} }
...@@ -126,6 +126,8 @@ function ($) { ...@@ -126,6 +126,8 @@ function ($) {
relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time); relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time);
absoluteTime = dashboard.formatDate(seriesHoverInfo.time); absoluteTime = dashboard.formatDate(seriesHoverInfo.time);
seriesHoverInfo.sort(byToolTipValue);
for (i = 0; i < seriesHoverInfo.length; i++) { for (i = 0; i < seriesHoverInfo.length; i++) {
hoverInfo = seriesHoverInfo[i]; hoverInfo = seriesHoverInfo[i];
...@@ -138,7 +140,7 @@ function ($) { ...@@ -138,7 +140,7 @@ function ($) {
value = series.formatValue(hoverInfo.value); value = series.formatValue(hoverInfo.value);
seriesHtml += '<div class="graph-tooltip-list-item"><div class="graph-tooltip-series-name">'; seriesHtml += '<div class="graph-tooltip-list-item"><div class="graph-tooltip-series-name">';
seriesHtml += '<i class="fa fa-minus" style="color:' + series.color +';"></i> ' + series.label + ':</div>'; seriesHtml += '<i class="fa fa-minus" style="color:' + hoverInfo.color +';"></i> ' + hoverInfo.label + ':</div>';
seriesHtml += '<div class="graph-tooltip-value">' + value + '</div></div>'; seriesHtml += '<div class="graph-tooltip-value">' + value + '</div></div>';
plot.highlight(i, hoverInfo.hoverIndex); plot.highlight(i, hoverInfo.hoverIndex);
} }
...@@ -174,5 +176,9 @@ function ($) { ...@@ -174,5 +176,9 @@ function ($) {
}); });
} }
function byToolTipValue(a, b) {
return parseFloat(b.value) - parseFloat(a.value);
}
return GraphTooltip; return GraphTooltip;
}); });
...@@ -101,6 +101,10 @@ function (angular, _, $) { ...@@ -101,6 +101,10 @@ function (angular, _, $) {
$container.empty(); $container.empty();
// Set min-width if side style and there is a value, otherwise remove the CSS propery
var width = panel.legend.rightSide && panel.legend.sideWidth ? panel.legend.sideWidth + "px" : "";
$container.css("min-width", width);
$container.toggleClass('graph-legend-table', panel.legend.alignAsTable === true); $container.toggleClass('graph-legend-table', panel.legend.alignAsTable === true);
if (panel.legend.alignAsTable) { if (panel.legend.alignAsTable) {
......
...@@ -97,7 +97,8 @@ function (angular, app, _, $) { ...@@ -97,7 +97,8 @@ function (angular, app, _, $) {
plotCss.bottom = '5px'; plotCss.bottom = '5px';
plotCss.left = '-5px'; plotCss.left = '-5px';
plotCss.width = (width - 10) + 'px'; plotCss.width = (width - 10) + 'px';
plotCss.height = (height - 45) + 'px'; var dynamicHeightMargin = height <= 100 ? 5 : (Math.round((height/100)) * 15) + 5;
plotCss.height = (height - dynamicHeightMargin) + 'px';
} }
else { else {
plotCss.bottom = "0px"; plotCss.bottom = "0px";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment