Skip to main content
Version: nightly

OpenTelemetry Protocol (OTLP)

OpenTelemetry is a vendor-neutral open-source observability framework for instrumenting, generating, collecting, and exporting telemetry data such as traces, metrics, logs. The OpenTelemetry Protocol (OTLP) defines the encoding, transport, and delivery mechanism of telemetry data between telemetry sources, intermediate processes such as collectors and telemetry backends.

OTLP/HTTP

GreptimeDB is an observability backend to consume OpenTelemetry Metrics natively via OTLP/HTTP protocol.

API

To send OpenTelemetry Metrics to GreptimeDB through OpenTelemetry SDK libraries, use the following information:

  • URL: https://<host>/v1/otlp/v1/metrics
  • Headers:
    • X-Greptime-DB-Name: <dbname>
    • Authorization: Basic authentication, which is a Base64 encoded string of <username>:<password>. For more information, please refer to Authentication and HTTP API

The request uses binary protobuf to encode the payload, so you need to use packages that support HTTP/protobuf. For example, in Node.js, you can use exporter-trace-otlp-proto; in Go, you can use go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp; in Java, you can use io.opentelemetry:opentelemetry-exporter-otlp; and in Python, you can use opentelemetry-exporter-otlp-proto-http.

NOTE

The package names may change according to OpenTelemetry, so we recommend that you refer to the official OpenTelemetry documentation for the most up-to-date information.

For more information about the OpenTelemetry SDK, please refer to the official documentation for your preferred programming language.

Example Code

Here are some example codes about how to setup the request in different languages:

const auth = Buffer.from(`${username}:${password}`).toString('base64')
const exporter = new OTLPMetricExporter({
url: `https://${dbHost}/v1/otlp/v1/metrics`,
headers: {
Authorization: `Basic ${auth}`,
"X-Greptime-DB-Name": db,
},
timeoutMillis: 5000,
})

You can find executable demos on GitHub at the links: Go, Java, Python, and Node.js.

NOTE

The example codes above may be outdated according to OpenTelemetry. We recommend that you refer to the official OpenTelemetry documentation for the most up-to-date information.

For more information on the example code, please refer to the official documentation for your preferred programming language.

Data Model

The OTLP metrics data model is mapped to the GreptimeDB data model according to the following rules:

  • The name of the Metric will be used as the name of the GreptimeDB table, and the table will be automatically created if it does not exist.
  • All attributes, including resource attributes, scope attributes, and data point attributes, will be used as tag columns of the GreptimeDB table.
  • The timestamp of the data point will be used as the timestamp index of GreptimeDB, and the column name is greptime_timestamp.
  • The data of Gauge/Sum data types will be used as the field column of GreptimeDB, and the column name is greptime_value.
  • Each quantile of the Summary data type will be used as a separated data column of GreptimeDB, and the column name is greptime_pxx, where xx is the quantile, such as 90/99, etc.
  • Histogram and ExponentialHistogram are not supported yet, we may introduce the Histogram data type to natively support these two types in a later version.