Commit 2e610cb2 by bergquist

dashboards as cfg: move dash/ds config files to /provisioning/*

parent 50bc801f
......@@ -20,11 +20,8 @@ logs = data/log
# Directory where grafana will automatically scan and look for plugins
plugins = data/plugins
# Config files containing datasources that will be configured at startup
datasources = conf/datasources
# Config files containing folders to read dashboards from and insert into the database.
dashboards = conf/dashboards
# folder that contains provisioning config files that grafana will apply on startup and while running.
provisioning = conf/provisioning
#################################### Server ##############################
[server]
......
- name: 'default'
org_id: 1
folder: ''
type: file
options:
folder: /var/lib/grafana/dashboards
\ No newline at end of file
# list of datasources that should be deleted from the database
delete_datasources:
- name: Graphite
org_id: 1
# list of datasources to insert/update depending
# whats available in the datbase
datasources:
# <string, required> name of the datasource. Required
- name: Graphite
# <string, required> datasource type. Required
type: graphite
# <string, required> access mode. direct or proxy. Required
access: proxy
# <int> org id. will default to org_id 1 if not specified
org_id: 1
# <string> url
url: http://localhost:8080
# <string> database password, if used
password:
# <string> database user, if used
user:
# <string> database name, if used
database:
# <bool> enable/disable basic auth
basic_auth:
# <string> basic auth username
basic_auth_user:
# <string> basic auth password
basic_auth_password:
# <bool> enable/disable with credentials headers
with_credentials:
# <bool> mark as default datasource. Max one per org
is_default:
# <map> fields that will be converted to json and stored in json_data
json_data:
graphiteVersion: "1.1"
tlsAuth: true
tlsAuthWithCACert: true
# <string> json object of data that will be encrypted.
secure_json_data:
tlsCACert: "..."
tlsClientCert: "..."
tlsClientKey: "..."
version: 1
# <bool> allow users to edit datasources from the UI.
editable: false
......@@ -31,10 +31,10 @@ case "$1" in
cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml
fi
if [ ! -f $DATASOURCES_CFG_DIR ]; then
mkdir -p /etc/grafana/dashboards /etc/grafana/datasources
cp /usr/share/grafana/conf/dashboards/sample.yaml $DASHBOARDS_CFG_DIR/sample.yaml
cp /usr/share/grafana/conf/datasources/sample.yaml $DATASOURCES_CFG_DIR/sample.yaml
if [ ! -f $PROVISIONING_CFG_DIR ]; then
mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources
cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml
cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml
fi
# configuration files should not be modifiable by grafana user, as this can be a security issue
......
......@@ -18,9 +18,7 @@ RESTART_ON_UPGRADE=true
PLUGINS_DIR=/var/lib/grafana/plugins
DATASOURCES_CFG_DIR=/etc/grafana/datasources
DASHBOARDS_CFG_DIR=/etc/grafana/dashboards
PROVISIONING_CFG_DIR=/etc/grafana/provisioning
# Only used on systemd systems
PID_FILE_DIR=/var/run/grafana
......@@ -33,8 +33,7 @@ DATA_DIR=/var/lib/grafana
PLUGINS_DIR=/var/lib/grafana/plugins
LOG_DIR=/var/log/grafana
CONF_FILE=$CONF_DIR/grafana.ini
DATASOURCES_CFG_DIR=$CONF_DIR/datasources
DASHBOARDS_CFG_DIR=$CONF_DIR/dashboards
PROVISIONING_CFG_DIR=$CONF_DIR/provisioning
MAX_OPEN_FILES=10000
PID_FILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/$NAME
......@@ -57,7 +56,7 @@ if [ -f "$DEFAULT" ]; then
. "$DEFAULT"
fi
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.datasources=$DATASOURCES_CFG_DIR cfg:default.paths.dashboards=$DASHBOARDS_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"
function checkUser() {
if [ `id -u` -ne 0 ]; then
......
......@@ -14,14 +14,13 @@ Restart=on-failure
WorkingDirectory=/usr/share/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.datasources=${DATASOURCES_CFG_DIR} \
cfg:default.paths.dashboards=${DASHBOARDS_CFG_DIR}
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.provisioning=${PROVISIONING_CFG_DIR}
LimitNOFILE=10000
......
......@@ -45,10 +45,10 @@ if [ $1 -eq 1 ] ; then
cp /usr/share/grafana/conf/ldap.toml /etc/grafana/ldap.toml
fi
if [ ! -f $DATASOURCES_CFG_DIR ]; then
mkdir -p /etc/grafana/dashboards /etc/grafana/datasources
cp /usr/share/grafana/conf/dashboards/sample.yaml $DASHBOARDS_CFG_DIR/sample.yaml
cp /usr/share/grafana/conf/datasources/sample.yaml $DATASOURCES_CFG_DIR/sample.yaml
if [ ! -f $PROVISIONING_CFG_DIR ]; then
mkdir -p $PROVISIONING_CFG_DIR/dashboards $PROVISIONING_CFG_DIR/datasources
cp /usr/share/grafana/conf/provisioning/dashboards/sample.yaml $PROVISIONING_CFG_DIR/dashboards/sample.yaml
cp /usr/share/grafana/conf/provisioning/datasources/sample.yaml $PROVISIONING_CFG_DIR/datasources/sample.yaml
fi
# Set user permissions on /var/log/grafana, /var/lib/grafana
......
......@@ -32,8 +32,7 @@ DATA_DIR=/var/lib/grafana
PLUGINS_DIR=/var/lib/grafana/plugins
LOG_DIR=/var/log/grafana
CONF_FILE=$CONF_DIR/grafana.ini
DATASOURCES_CFG_DIR=$CONF_DIR/datasources
DASHBOARDS_CFG_DIR=$CONF_DIR/dashboards
PROVISIONING_CFG_DIR=$CONF_DIR/provisioning
MAX_OPEN_FILES=10000
PID_FILE=/var/run/$NAME.pid
DAEMON=/usr/sbin/$NAME
......@@ -61,7 +60,7 @@ fi
# overwrite settings from default file
[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.datasources=$DATASOURCES_CFG_DIR cfg:default.paths.dashboards=$DASHBOARDS_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"
DAEMON_OPTS="--pidfile=${PID_FILE} --config=${CONF_FILE} cfg:default.paths.provisioning=$PROVISIONING_CFG_DIR cfg:default.paths.data=${DATA_DIR} cfg:default.paths.logs=${LOG_DIR} cfg:default.paths.plugins=${PLUGINS_DIR}"
function isRunning() {
status -p $PID_FILE $NAME > /dev/null 2>&1
......
......@@ -18,9 +18,7 @@ RESTART_ON_UPGRADE=true
PLUGINS_DIR=/var/lib/grafana/plugins
DATASOURCES_CFG_DIR=/etc/grafana/datasources
DASHBOARDS_CFG_DIR=/etc/grafana/dashboards
PROVISIONING_CFG_DIR=/etc/grafana/provisioning
# Only used on systemd systems
PID_FILE_DIR=/var/run/grafana
......@@ -14,14 +14,13 @@ Restart=on-failure
WorkingDirectory=/usr/share/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.datasources=${DATASOURCES_CFG_DIR} \
cfg:default.paths.dashboards=${DASHBOARDS_CFG_DIR}
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.provisioning=${PROVISIONING_CFG_DIR}
LimitNOFILE=10000
TimeoutStopSec=20
......
......@@ -2,6 +2,7 @@ package provisioning
import (
"context"
"path"
"path/filepath"
"github.com/grafana/grafana/pkg/services/provisioning/dashboards"
......@@ -10,12 +11,14 @@ import (
)
func Init(ctx context.Context, homePath string, cfg *ini.File) error {
datasourcePath := makeAbsolute(cfg.Section("paths").Key("datasources").String(), homePath)
provisioningPath := makeAbsolute(cfg.Section("paths").Key("provisioning").String(), homePath)
datasourcePath := path.Join(provisioningPath, "datasources")
if err := datasources.Provision(datasourcePath); err != nil {
return err
}
dashboardPath := makeAbsolute(cfg.Section("paths").Key("dashboards").String(), homePath)
dashboardPath := path.Join(provisioningPath, "dashboards")
_, err := dashboards.Provision(ctx, dashboardPath)
if err != nil {
return err
......
......@@ -50,13 +50,12 @@ var (
BuildStamp int64
// Paths
LogsPath string
HomePath string
DataPath string
PluginsPath string
DatasourcesPath string
DashboardsPath string
CustomInitPath = "conf/custom.ini"
LogsPath string
HomePath string
DataPath string
PluginsPath string
ProvisioningPath string
CustomInitPath = "conf/custom.ini"
// Log settings.
LogModes []string
......@@ -475,9 +474,7 @@ func NewConfigContext(args *CommandLineArgs) error {
Env = Cfg.Section("").Key("app_mode").MustString("development")
InstanceName = Cfg.Section("").Key("instance_name").MustString("unknown_instance_name")
PluginsPath = makeAbsolute(Cfg.Section("paths").Key("plugins").String(), HomePath)
DatasourcesPath = Cfg.Section("paths").Key("datasources").String()
DashboardsPath = Cfg.Section("paths").Key("dashboards").String()
ProvisioningPath = makeAbsolute(Cfg.Section("paths").Key("provisioning").String(), HomePath)
server := Cfg.Section("server")
AppUrl, AppSubUrl = parseAppUrlAndSubUrl(server)
......@@ -672,6 +669,6 @@ func LogConfigurationInfo() {
logger.Info("Path Data", "path", DataPath)
logger.Info("Path Logs", "path", LogsPath)
logger.Info("Path Plugins", "path", PluginsPath)
logger.Info("Path Datasources", "path", DatasourcesPath)
logger.Info("Path Provisioning", "path", ProvisioningPath)
logger.Info("App mode " + Env)
}
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