This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.

Grafana Cloud Enterprise Open source

Configure the OpenTSDB data source

This document explains how to configure the OpenTSDB data source in Grafana.

Before you begin

Before configuring the OpenTSDB data source, ensure you have:

  • Grafana permissions: Organization administrator role to add data sources.
  • OpenTSDB instance: A running OpenTSDB server (version 2.1 or later recommended).
  • Network access: The Grafana server can reach the OpenTSDB HTTP API endpoint (default port 4242).
  • Metrics in OpenTSDB: For autocomplete to work, metrics must exist in your OpenTSDB database.

Add the data source

To add and configure the OpenTSDB data source:

  1. Click Connections in the left-side menu.
  2. Click Add new connection.
  3. Type OpenTSDB in the search bar.
  4. Select OpenTSDB.
  5. Click Add new data source in the upper right.
  6. Configure the data source settings as described in the following sections.

Configuration options

The following table describes the available configuration options:

SettingDescription
NameThe data source name. This is how you refer to the data source in panels and queries.
DefaultToggle to make this the default data source for new panels.
URLThe HTTP protocol, IP address, and port of your OpenTSDB server. The default port is 4242. Example: http://localhost:4242.
Allowed cookiesCookies to forward to the data source. Use this when your OpenTSDB server requires specific cookies for authentication.
TimeoutHTTP request timeout in seconds. Increase this value for slow networks or complex queries.

Auth settings

Configure authentication if your OpenTSDB server requires it:

SettingDescription
Basic authEnable to authenticate with a username and password. When enabled, enter the username and password in the fields that appear.
With CredentialsEnable to send cookies or auth headers with cross-site requests. Use this when OpenTSDB is on a different domain and requires credentials.
TLS Client AuthenticationEnable to use client certificates for authentication. Requires configuring client certificate and key.
Skip TLS VerifyEnable to skip verification of the OpenTSDB server’s TLS certificate. Only use this in development environments.
Forward OAuth IdentityEnable to forward the user’s OAuth token to the data source. Useful when OpenTSDB is behind an OAuth-protected proxy.
Custom HTTP HeadersAdd custom headers to all requests sent to OpenTSDB. Useful for API keys or custom authentication schemes.

OpenTSDB settings

Configure these settings based on your OpenTSDB server version and configuration:

SettingDescription
VersionSelect your OpenTSDB version. This affects available query features. Refer to the following section for version-specific features.
ResolutionThe resolution of your metric data. Select second for second-precision timestamps or millisecond for millisecond-precision timestamps.
Lookup limitMaximum number of results returned by suggest and lookup API calls. Default is 1000. Increase this if you have many metrics or tag values.

Version-specific features

The version setting enables different query features in Grafana:

VersionAvailable features
<=2.1Basic queries with tags. Uses legacy tag-based filtering.
==2.2Adds filter support (literal_or, wildcard, regexp, and more). Filters replace tags for more flexible queries.
==2.3Adds explicit tags support for rate calculations and additional filter types.
==2.4Adds fill policy support for downsampling (none, null, zero, nan). Enables arrays=true for alerting compatibility.

Select the version that matches your OpenTSDB server. If you’re unsure, check your OpenTSDB version with the /api/version endpoint.

Verify the connection

Click Save & test to verify that Grafana can connect to your OpenTSDB server. A successful test confirms that the URL is correct and the server is responding.

If the test fails, refer to Troubleshooting for common issues and solutions.

Provision the data source

You can define and configure the data source in YAML files as part of the Grafana provisioning system. For more information about provisioning, and for available configuration options, refer to Provisioning Grafana.

YAML example

The following example provisions an OpenTSDB data source:

YAML
apiVersion: 1

datasources:
  - name: OpenTSDB
    type: opentsdb
    access: proxy
    url: http://localhost:4242
    jsonData:
      # OpenTSDB version: 1 = <=2.1, 2 = 2.2, 3 = 2.3, 4 = 2.4
      tsdbVersion: 3
      # Resolution: 1 = second, 2 = millisecond
      tsdbResolution: 1
      # Maximum results for suggest/lookup API calls
      lookupLimit: 1000

YAML example with basic authentication

The following example provisions an OpenTSDB data source with basic authentication:

YAML
apiVersion: 1

datasources:
  - name: OpenTSDB
    type: opentsdb
    access: proxy
    url: http://localhost:4242
    basicAuth: true
    basicAuthUser: <USERNAME>
    jsonData:
      tsdbVersion: 3
      tsdbResolution: 1
      lookupLimit: 1000
    secureJsonData:
      basicAuthPassword: <PASSWORD>

YAML example with custom headers

The following example provisions an OpenTSDB data source with custom HTTP headers:

YAML
apiVersion: 1

datasources:
  - name: OpenTSDB
    type: opentsdb
    access: proxy
    url: http://localhost:4242
    jsonData:
      tsdbVersion: 3
      tsdbResolution: 1
      lookupLimit: 1000
      httpHeaderName1: X-Custom-Header
    secureJsonData:
      httpHeaderValue1: <HEADER_VALUE>

The following table describes the available fields:

FieldTypeDescription
basicAuthbooleanEnable basic authentication.
basicAuthUserstringUsername for basic authentication.
jsonData.tsdbVersionnumberOpenTSDB version: 1 (<=2.1), 2 (2.2), 3 (2.3), 4 (2.4).
jsonData.tsdbResolutionnumberTimestamp resolution: 1 (second), 2 (millisecond).
jsonData.lookupLimitnumberMaximum results for suggest and lookup API calls. Default: 1000.
jsonData.httpHeaderName1stringName of a custom HTTP header. Use incrementing numbers for multiple headers.
secureJsonData.basicAuthPasswordstringPassword for basic authentication.
secureJsonData.httpHeaderValue1stringValue for the custom HTTP header.

Provision with Terraform

You can provision the OpenTSDB data source using Terraform with the Grafana Terraform provider.

For more information about provisioning resources with Terraform, refer to the Grafana as code using Terraform documentation.

Terraform example

The following example provisions an OpenTSDB data source:

hcl
terraform {
  required_providers {
    grafana = {
      source  = "grafana/grafana"
      version = ">= 2.0.0"
    }
  }
}

provider "grafana" {
  url  = "<YOUR_GRAFANA_URL>"
  auth = "<YOUR_SERVICE_ACCOUNT_TOKEN>"
}

resource "grafana_data_source" "opentsdb" {
  type = "opentsdb"
  name = "OpenTSDB"
  url  = "http://localhost:4242"

  json_data_encoded = jsonencode({
    # OpenTSDB version: 1 = <=2.1, 2 = 2.2, 3 = 2.3, 4 = 2.4
    tsdbVersion = 3
    # Resolution: 1 = second, 2 = millisecond
    tsdbResolution = 1
    # Maximum results for suggest/lookup API calls
    lookupLimit = 1000
  })
}

Terraform example with basic authentication

The following example provisions an OpenTSDB data source with basic authentication:

hcl
resource "grafana_data_source" "opentsdb_auth" {
  type                = "opentsdb"
  name                = "OpenTSDB"
  url                 = "http://localhost:4242"
  basic_auth_enabled  = true
  basic_auth_username = "<USERNAME>"

  json_data_encoded = jsonencode({
    tsdbVersion    = 3
    tsdbResolution = 1
    lookupLimit    = 1000
  })

  secure_json_data_encoded = jsonencode({
    basicAuthPassword = "<PASSWORD>"
  })
}

Replace the following placeholders:

  • <YOUR_GRAFANA_URL>: Your Grafana instance URL (for example, https://your-org.grafana.net for Grafana Cloud)
  • <YOUR_SERVICE_ACCOUNT_TOKEN>: A service account token with data source permissions
  • <USERNAME>: The username for basic authentication
  • <PASSWORD>: The password for basic authentication

Next steps

Now that you’ve configured OpenTSDB, you can: