In the above example you see two InfluxDB datasources, one for metrics and a seperate used for dashboard storage. You can use the same InfluxDB
database for both. But it is probably a good idea to keep them seperate. The InfluxDB databases need to exist, grafana does not create
them.
### Graphite & Elasticsearch setup example
```javascript
datasources: {
graphite: {
type: 'graphite',
url: "http://my.graphite.server.com:8080",
},
elasticsearch: {
type: 'elasticsearch',
url: "http://my.elastic.server.com:9200",
index: 'grafana-dash',
grafanaDB: true,
}
},
```
If you use Graphite you need Elasticsearch if you want to store & search dashboards. You can also use json and scripted dashboards if
you really do not want to setup Elasticsearch.
### OpenTSDB & Elasticsearch setup example
```javascript
datasources: {
opentsdb: {
type: 'opentsdb',
url: "http://my.opentsdb.server.com:4242",
},
elasticsearch: {
type: 'elasticsearch',
url: "http://my.elastic.server.com:9200",
index: 'grafana-dash',
grafanaDB: true,
}
},
```
Please view [this page](/docs/features/opentsdb) for details on how to configure OpenTSDB to work with Grafana.
### Elasticsearch & CORS
As of Elasticsearch v1.4 CORS is disabled by default. This needs to be enabled in the Elasticsearch config file, otherwise grafana will not be able to access Elasticsearch.
```
http.cors.enabled: true
http.cors.allow-origin: *
```
Instead of the wildcard you can put your full grafana webserver address (including http:// and port)
### Basic authentication
If your Graphite or Elasticsearch server require basic authentication you can specify the username and password in the url.
For example `"http://admin:secret@my.graphite.com"`
## Global configuration options
```javascript
// specify the limit for dashboard search results
search: {
max_results: 20
},
// default start dashboard
default_route: '/dashboard/file/default.json',
// set to false to disable unsaved changes warning
unsaved_changes_warning: true,
// set the default timespan for the playlist feature
// Example: "1m", "1h"
playlist_timespan: "1m",
// If you want to specify password before saving, please specify it bellow
// The purpose of this password is not security, but to stop some users from accidentally changing dashboards
admin: {
password: ''
},
// Add your own custom pannels
plugins: {
panels: []
}
```
## Graphite server config
If you haven't used an alternative dashboard for graphite before you need to enable CORS (Cross Origin Resource Sharing).
This is only required if Grafana is hosted on a different web domain from your graphite-web.
For Apache 2.x:
```javascript
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, OPTIONS"
Header set Access-Control-Allow-Headers "origin, authorization, accept"
```
Note that using `"*"` leaves your graphite instance quite open so you might want to consider
using `"http://my.grafana.com"` in place of `"*"`
If your Graphite web is proteced by basic authentication, you have to enable the HTTP verb OPTIONS. Take note that
when using basic auth **Access-Control-Allow-Origin** must not be set to a wildcard, also the header
**Access-Control-Allow-Credentials** must be specified. This looks like the following for Apache:
```html
Header set Access-Control-Allow-Origin "http://mygrafana.com:5656"
Header set Access-Control-Allow-Methods "GET, OPTIONS"
Header set Access-Control-Allow-Headers "origin, authorization, accept"
Header set Access-Control-Allow-Credentials true
<Location/>
AuthName "graphs restricted"
AuthType Basic
AuthUserFile /etc/apache2/htpasswd
<LimitExceptOPTIONS>
require valid-user
</LimitExcept>
</Location>
```
For nginx:
```javascript
auth_basic "Restricted";
auth_basic_user_file /path/to/my/htpasswd/file;
if ($http_origin ~* (https?://[^/]*\.somedomain\.com(:[0-9]+)?)) { #Test if request is from allowed domain, you can use multiple if
set $cors "true"; #statements to allow multiple domains, simply setting $cors to true in each one.
}
if ($cors = 'true') {
add_header Access-Control-Allow-Origin $http_origin; #this mirrors back whatever domain the request came from as authorized, as
add_header "Access-Control-Allow-Credentials" "true"; #as long as it matches one of your if statements