Commit 7ffdb488 by Torkel Ödegaard

Updated opentsdb docs article with info on adding the data source

parent 2c1188f6
......@@ -6,106 +6,28 @@ page_keywords: grafana, opentsdb, documentation
# OpenTSDB Guide
Here you will find some configuration tips for how to setup Grafana and OpenTSDB.
## Adding the data source to Grafana
Open the side menu by clicking the the Grafana icon in the top header. In the side menu under the `Dashboards` link you
should find a link named `Data Sources`. If this link is missing in the side menu it means that your current
user does not have the `Admin` role for the current organization.
## OpenTSDB configuration
![](/img/v2/add_datasource_opentsdb.png)
For OpenTSDB to work in Grafana you will either be needing to run the latest OpenTSDB
version built from the `next` branch that includes built in support for remote
api usage (CORS). This was merged into the next branch with [this issue](https://github.com/OpenTSDB/opentsdb/pull/333).
Now click the `Add new` link in the top header.
If you upgrade you have to set the OpenTSDB setting `tsd.http.request.cors_domains` to your
grafana webserver domain name.
Name | Description
------------ | -------------
Name | The data source name, important that this is the same as in Grafana v1.x if you plan to import old dashboards.
Default | Default data source means that it will be pre-selected for new panels.
Url | The http protocol, ip and port of you opentsdb server (default port is usually 4242)
Access | Proxy = access via Grafana backend, Direct = access directory from browser.
If you do not want to upgrade OpenTSDB you need to setup an nginx proxy that will add the necessary CORS
HTTP headers.
Example nginx config:
Replace:
- **OPENTSDB_HOST** (2 instances) - Hostname or IP address of the OpenTSDB server
- **OPENTSDB_PORT** (1 instance) - Port number of the OpenTSDB server
- **GRAFANA_DOMAIN** (1 instance) - Domain/Hostname of the Grafana server
```nginx
upstream opentsdb {
server OPENTSDB_HOST:OPENTSDB_PORT fail_timeout=0;
}
server {
listen *:4243;
location / {
# Regex to whitelist systems
if ($http_origin ~* (https?://([a-z0-9._-]*\.)?GRAFANA_DOMAIN(:[0-9]+)?)) {
set $cors "true";
}
# OPTIONS indicates a CORS pre-flight request
if ($request_method = 'OPTIONS') {
set $cors "${cors}-options";
}
# If it's OPTIONS, then it's a CORS preflight request so respond immediately with no response body
if ($cors = "true-options") {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since';
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain charset=UTF-8';
return 204;
}
# Proxy the request
proxy_set_header X-Host OPENTSDB_HOST;
proxy_set_header X-Forwarded-For $Proxy_add_x_forwarded_for;
proxy_set_header Authorization "";
proxy_pass http://opentsdb;
proxy_redirect default;
proxy_buffer_size 16k;
proxy_buffers 8 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_read_timeout 120;
# Strip any OpenTSDB-generated CORS headers that overlap with our own
proxy_hide_header 'Access-Control-Allow-Origin';
proxy_hide_header 'Access-Control-Allow-Credentials';
proxy_hide_header 'Access-Control-Allow-Headers';
# if it's a GET or POST, set the standard CORS responses header
if ($cors = "true") {
# Add our own CORS headers
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' '*';
}
}
}
```
## Grafana config
In config.js specify your opentsdb datasource:
```javascript
datasources: {
'OpenTSDB-TEST': {
default: true,
type: 'opentsdb',
url: "http://my_opentsdb_server:4242"
}
},
```
## Create a graph
## Query editor
Open a graph in edit mode by click the title.
![](/img/opentsdb/editor_v1.png)
![](/img/v2/opentsdb_query_editor.png)
For details on opentsdb metric queries
checkout the offical [OpenTSDB documentation](http://opentsdb.net/docs/build/html/index.html)
For details on opentsdb metric queries checkout the offical [OpenTSDB documentation](http://opentsdb.net/docs/build/html/index.html)
......
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