Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/greptimecloud/integrations/otlp.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exporters:
authenticator: basicauth/client
headers:
x-greptime-db-name: '<dbname>'
x-greptime-pipeline-name: 'greptime_trace_v1'
x-greptime-pipeline-name: 'greptime_trace_v2'
otlphttp/logs:
endpoint: 'https://<host>/v1/otlp'
auth:
Expand Down Expand Up @@ -74,6 +74,8 @@ service:
exporters: [otlphttp/metrics]
```

If `opentelemetry_traces` is a v1 table, [send v2 traces to a new table](https://docs.greptime.com/user-guide/traces/read-write/#existing-v1-trace-tables).

## Grafana Alloy

If you prefer to use [Grafana Alloy](https://grafana.com/docs/alloy/latest/)'s OpenTelemetry exporter, you can use the following configuration to send your data.
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sql/information-schema/table-semantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The output is as follows:
- `unknown` — could not be determined when the option was stamped.
- `source`: The ingestion ecosystem that wrote the data. One of `opentelemetry`, `prometheus`, `influxdb`, `opentsdb`, `elasticsearch`, `loki`, `custom`, `mixed`, or `unknown`. `mixed` means one table received data from more than one source; `unknown` means it could not be determined.
- `source_version`: The version of the source protocol. The Prometheus remote write path stamps `1.0` or `2.0`; other paths leave it empty.
- `pipeline`: A free-form identifier of the internal ingestion data model. Today the OTLP trace path stamps `greptime_trace_v1` or `greptime_trace_v2`, depending on the selected pipeline; other values can be set manually. It is the signal-agnostic successor to the `table_data_model` option.
- `pipeline`: A free-form identifier of the internal ingestion data model. Today the OTLP trace path stamps `greptime_trace_v2` or `greptime_trace_v1`, depending on the [selected trace pipeline](/user-guide/traces/data-model.md#data-model-versioning); other values can be set manually. It is the signal-agnostic successor to the `table_data_model` option.
- `metadata_quality`: How the metric type metadata was obtained — that is, how much you can trust the `metric.type` value. One of:
- `declared` — the ingestion protocol stated the instrument type explicitly (for example OTLP metrics carry the type). Trustworthy.
- `inferred` — the type was guessed from the metric name (for example a Prometheus `_total` suffix is read as a counter). May be wrong for non-conventional names.
Expand Down
6 changes: 4 additions & 2 deletions docs/user-guide/ingest-data/for-observability/fluent-bit.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ Use a separate output for each signal because GreptimeDB uses signal-specific he
Log_response_payload True
Tls Off
Tls.verify Off
Header X-Greptime-Pipeline-Name greptime_trace_v1
Header X-Greptime-Pipeline-Name greptime_trace_v2
Header X-Greptime-DB-Name <dbname>
```

If `opentelemetry_traces` is a v1 table, [send v2 traces to a new table](/user-guide/traces/read-write.md#existing-v1-trace-tables).

- `Metrics_uri`, `Logs_uri`, and `Traces_uri`: The endpoints for metrics, logs, and traces.
- `Match`: The signal-specific tag configured on the corresponding Fluent Bit input.
- `http_user` and `http_passwd`: The [authentication credentials](/user-guide/deployments-administration/authentication/static.md) for GreptimeDB. Add them to each output when authentication is enabled.

In this example, the OpenTelemetry OTLP/HTTP API is used. For signal-specific headers and options, see the OpenTelemetry API sections for [metrics](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api), [logs](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api-1), and [traces](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api-2).
In this example, the OpenTelemetry OTLP/HTTP API is used. For signal-specific headers and options, see the OpenTelemetry API sections for [metrics](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api), [logs](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api-1), and [traces](/user-guide/ingest-data/for-observability/opentelemetry.md#otlphttp-api-2). The trace output above uses `greptime_trace_v2`; see [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning) to compare it with `greptime_trace_v1`.

## Prometheus Remote Write

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ To send OpenTelemetry traces data to GreptimeDB through OpenTelemetry SDK librar
- `Authorization`: `Basic` authentication.
- `X-Greptime-DB-Name`: `<dbname>`
- `X-Greptime-Trace-Table-Name`: `<table_name>` (optional) - The table name to store the traces. If not provided, the default table name is `opentelemetry_traces`.
- `X-Greptime-Pipeline-Name`: `greptime_trace_v1` or `greptime_trace_v2` (required) - The pipeline name to process the traces.
- `X-Greptime-Pipeline-Name`: `greptime_trace_v2` or `greptime_trace_v1` (required) - The pipeline name to process the traces; see [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning).

If `opentelemetry_traces` is a v1 table, [send v2 traces to a new table](/user-guide/traces/read-write.md#existing-v1-trace-tables).

GreptimeDB accepts **protobuf encoded traces data** via **HTTP protocol**.

Expand All @@ -409,11 +411,11 @@ You can directly send OpenTelemetry traces data to GreptimeDB, or use OpenTeleme
### Data Model

See [Trace Data Modeling](/user-guide/traces/data-model.md) for table schemas,
attribute storage, and table options for `greptime_trace_v1` and `greptime_trace_v2`.
attribute storage, and table options for `greptime_trace_v2` and `greptime_trace_v1`.

### Schema Evolution and Partial Success

The `greptime_trace_v1` model automatically adds new flattened attribute columns. When a trace table already exists, GreptimeDB reconciles incoming attribute value types with the existing table schema. Compatible scalar values can be coerced to the existing column type, and existing `Int64` attribute columns may be widened to `Float64` when incoming values contain both integers and floats.
The `greptime_trace_v2` model stores attributes in `JSON2` columns without adding table columns for new attribute keys. If you use `greptime_trace_v1`, GreptimeDB automatically adds new flattened attribute columns and reconciles incoming attribute value types with the existing table schema: compatible scalar values can be coerced to the existing column type, and existing `Int64` attribute columns may be widened to `Float64` when incoming values contain both integers and floats.

If some spans in a trace request cannot be written because of incompatible schema or values, GreptimeDB may still accept the other spans and return an OTLP `partial_success` response with `rejected_spans` and `error_message`. If all spans are rejected, the endpoint returns a `400 Bad Request` response.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ exporters:
# authenticator: basicauth/client
headers:
# x-greptime-db-name: '<your_db_name>'
x-greptime-pipeline-name: 'greptime_trace_v1'
x-greptime-pipeline-name: 'greptime_trace_v2'
tls:
insecure: true
otlp_http/logs:
Expand Down Expand Up @@ -68,12 +68,14 @@ service:
exporters: [otlp_http/metrics]
```

If `opentelemetry_traces` is a v1 table, [send v2 traces to a new table](/user-guide/traces/read-write.md#existing-v1-trace-tables).

In the above configuration, we define a receiver `otlp` that can receive data from OpenTelemetry. We also define three exporters: `otlp_http/traces`, `otlp_http/logs`, and `otlp_http/metrics`, which send data to the OTLP endpoint of GreptimeDB.

Based on the OTLP/HTTP protocol, we have added some headers to specify certain parameters, such as `x-greptime-pipeline-name` and `x-greptime-log-table-name`:
* The `x-greptime-pipeline-name` header is used to specify the pipeline name to use, and,
* the `x-greptime-pipeline-params` header is used to pass parameters to the pipeline, and,
* the `x-greptime-log-table-name` header is used to specify the table name in GreptimeDB where the data will be written.
* The `x-greptime-pipeline-name` header selects the pipeline. For traces, see [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning).
* The `x-greptime-pipeline-params` header passes parameters to the pipeline.
* The `x-greptime-log-table-name` header specifies the table name in GreptimeDB where the data will be written.

If you have enabled [authentication](/user-guide/deployments-administration/authentication/overview.md) in GreptimeDB, you need to use the `basicauth/client` extension to handle basic authentication.

Expand Down
27 changes: 15 additions & 12 deletions docs/user-guide/integrations/grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ description: Steps to configure GreptimeDB as a data source in Grafana using dif
# Grafana

GreptimeDB can be configured as a [Grafana data source](https://grafana.com/docs/grafana/latest/datasources/add-a-data-source/).
You have the option to connect GreptimeDB with Grafana using one of three data sources: [GreptimeDB](#greptimedb-data-source-plugin), [Prometheus](#prometheus-data-source), or [MySQL](#mysql-data-source).
Connect using the [GreptimeDB plugin](#greptimedb-data-source-plugin), [Prometheus](#prometheus-data-source),
or [MySQL](#mysql-data-source). To search for and view traces, use Grafana's
[Jaeger data source](/user-guide/query-data/jaeger.md#configure-the-grafana-jaeger-plugin).

## GreptimeDB data source plugin

Expand Down Expand Up @@ -101,11 +103,11 @@ series data: it calculates time intervals and returns the start of the interval
nearest to each timestamp, so rows are grouped into time-based bins (windows).
Apply an aggregate or selector function to each window.

Example (or raw SQL):
This raw SQL query sums input tokens per time bucket from a `greptime_trace_v2` table.

```sql
SELECT date_bin('$__interval', timestamp) AS time,
SUM(`span_attributes.gen_ai.usage.input_tokens`) AS input_tokens
SUM(span_attributes."gen_ai.usage.input_tokens"::BIGINT) AS input_tokens
FROM opentelemetry_traces
WHERE $__timeFilter(timestamp)
GROUP BY time
Expand Down Expand Up @@ -167,7 +169,9 @@ Performs an approximate time range query based on the value of context columns i

### Traces Query

Select the `Traces` query type for distributed tracing data.
Select the `Traces` query type to view traces with the GreptimeDB plugin.
For `greptime_trace_v2` tables, use Grafana's
[Jaeger data source](/user-guide/query-data/jaeger.md#configure-the-grafana-jaeger-plugin) to view spans and their attributes.

| Main Setting | Description |
| :-------------------- | :------------------------------------------------------------------------------------------------------ |
Expand All @@ -180,17 +184,16 @@ Select the `Traces` query type for distributed tracing data.
| **Start Time Column** | Default value: `timestamp` |
| **Duration Time Column** | Default value: `duration_nano` |
| **Duration Unit** | Default value: `nanoseconds` |
| **Tags Column** | Multiple selections allowed. Corresponds to columns starting with `span_attributes` (e.g., `span_attributes.http.method`). |
| **Service Tags Column** | Multiple selections allowed. Corresponds to columns starting with `resource_attributes` (e.g., `resource_attributes.host.name`). |
| **Tags Column** | For `greptime_trace_v1`, select one or more flattened span attribute columns, such as `span_attributes.http.request.method`. |
| **Service Tags Column** | For `greptime_trace_v1`, select one or more flattened resource attribute columns, such as `resource_attributes.host.name`. |

![Traces](/grafana/traceconfig.png)

#### Attribute Auto-Discovery

When the Trace ID query uses `SELECT *`, the plugin automatically discovers
all columns starting with `span_attributes.` and `resource_attributes.` and
includes them as expandable tags in the waterfall view. No need to manually
enumerate every attribute column.
For `greptime_trace_v1` tables, when the Trace ID query uses `SELECT *`, the plugin
shows columns with the `span_attributes.` and `resource_attributes.` prefixes as
expandable tags in the waterfall.

### SQL Macros

Expand Down Expand Up @@ -277,8 +280,8 @@ Enable **Auto-Select Columns** to automatically include them in log queries.
| Duration Time Column | Duration value | `duration_nano` |
| Duration Unit | Unit of duration column | `nanoseconds` |
| Start Time Column | Span start time | `timestamp` |
| Tags Column | Span attributes prefix | `span_attributes` |
| Service Tags Column | Resource attributes prefix | `resource_attributes` |
| Tags Column | Prefix for flattened span attributes in `greptime_trace_v1` | `span_attributes` |
| Service Tags Column | Prefix for flattened resource attributes in `greptime_trace_v1` | `resource_attributes` |

#### OTel Preset

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/protocols/postgresql-copy-in.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ with cur.copy("COPY app_logs FROM STDIN WITH (FORMAT otlp, signal 'logs')") as c
| `promote_scope_attrs` | Metrics | Boolean, default `false`. Promote scope attributes. |
| `translation_strategy` | Metrics | String, default `'UnderscoreEscapingWithSuffixes'`. See [accepted metric and label name translation strategies](/user-guide/ingest-data/for-observability/opentelemetry.md#prometheus-compatibility). |
| `table_name` | Logs, traces | String. Overrides the destination, like `x-greptime-log-table-name` or `x-greptime-trace-table-name`. See the routing rules below. |
| `pipeline_name` | Logs, traces | String. Selects a pipeline, like `x-greptime-pipeline-name`. Required for traces; omit for direct log ingestion. |
| `pipeline_name` | Logs, traces | String. Selects a pipeline, like `x-greptime-pipeline-name`. Required for traces; omit for direct log ingestion. See [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning). |
| `pipeline_version` | Logs, traces | String. Selects a pipeline version, like `x-greptime-pipeline-version`. |
| `pipeline_params` | Logs, traces | String, e.g. `'key1=value1&key2=value2'`. Passes parameters like `x-greptime-pipeline-params`. |
| `extract_keys` | Logs | Comma-separated string, e.g. `'host,env'`. Like `x-greptime-log-extract-keys`, extracts attributes during direct log ingestion. New columns are tags; existing columns keep their role (for example, a `host` field remains a field). |
Expand Down
7 changes: 4 additions & 3 deletions docs/user-guide/semantic-layer/declaring-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Conventions ship with the binary and are not configurable. An explicit declarati

### OTLP trace tables

Tables with `table_data_model` set to `greptime_trace_v1` or `greptime_trace_v2`
receive the following entity declarations without additional entity options. V1
reads flattened attribute columns; v2 reads JSON2 attributes using the same
Tables with `table_data_model` set to the `greptime_trace_v2` or `greptime_trace_v1`
[trace data model](/user-guide/traces/data-model.md#data-model-versioning)
receive the following entity declarations without additional entity options. V2
reads JSON2 attributes and v1 reads flattened attribute columns, using the same
declaration names:

| Entity | Identifying columns | Descriptive columns |
Expand Down
4 changes: 2 additions & 2 deletions docs/user-guide/semantic-layer/table-semantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The whitelist is closed: an unrecognized key under the prefix (such as `greptime
| `greptime.semantic.signal_type` | The telemetry signal the table represents. | `metric` / `trace` / `log` / `event` / `unknown` |
| `greptime.semantic.source` | The ingestion ecosystem that wrote the data. | `opentelemetry` / `prometheus` / `influxdb` / `opentsdb` / `loki` / `elasticsearch` / `custom` / `mixed` / `unknown` |
| `greptime.semantic.source_version` | The source protocol version. Stamped by the Prometheus remote write path. | `1.0` / `2.0` |
| `greptime.semantic.pipeline` | The internal ingestion data model. The signal-agnostic successor to `table_data_model`. | `greptime_trace_v1` / `greptime_trace_v2` |
| `greptime.semantic.pipeline` | The internal ingestion data model. The signal-agnostic successor to `table_data_model`; for traces, see [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning). | `greptime_trace_v2` / `greptime_trace_v1` |

### Trace keys

Expand Down Expand Up @@ -53,7 +53,7 @@ Supported auto-create paths stamp identity (`signal_type` + `source`). OTLP metr
| Ingestion path | `signal_type` | `source` | Additional keys |
| --- | --- | --- | --- |
| OTLP metrics | `metric` | `opentelemetry` | `metric.type`, `metric.unit`, `metric.temporality`, `metric.metadata_quality` = `declared`, `metric.original_name` |
| OTLP traces | `trace` | `opentelemetry` | `pipeline` = `greptime_trace_v1` or `greptime_trace_v2`, `trace.conventions` |
| OTLP traces | `trace` | `opentelemetry` | `pipeline` = `greptime_trace_v2` or `greptime_trace_v1` (see [trace data model versions](/user-guide/traces/data-model.md#data-model-versioning)), `trace.conventions` |
| OTLP logs | `log` | `opentelemetry` | — |
| Prometheus remote write | `metric` | `prometheus` | `source_version`, `metric.metadata_quality` = `inferred` |
| InfluxDB line protocol | `metric` | `influxdb` | identity only |
Expand Down
22 changes: 12 additions & 10 deletions docs/user-guide/traces/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ the moment, only built-in pipelines are supported.

First, the data types and features in GreptimeDB are evolving. For
forward-compatibility, we use the pipeline name for data model
versioning. Currently we have the following built-in pipeline for trace:
versioning. Currently we have the following built-in pipelines for traces:

- `greptime_trace_v1`: Flattens attributes into individual table columns.
- `greptime_trace_v2`: Stores attributes in three fixed `JSON2` columns.
- `greptime_trace_v1`: Flattens attributes into individual table columns.

Specify the data model in OpenTelemetry OTLP/HTTP requests with the
`x-greptime-pipeline-name` header. Choose v1 for flattened attribute columns,
or v2 for JSON2 attributes without adding a table column for every attribute key.
`x-greptime-pipeline-name` header. Choose `greptime_trace_v2` for JSON2 attributes
without adding a table column for every attribute key, or `greptime_trace_v1` for
flattened attribute columns.

We may introduce new data models by adding new available pipeline names. Note
that a new pipeline may not be compatible with previous ones, so you are
Expand Down Expand Up @@ -58,10 +59,11 @@ Unlike v1, v2 keeps `service.name` in `resource_attributes` as well as extractin
it into `service_name`. If the resource does not provide a usable service name,
the tag is `NULL`.

The table is created automatically on the first write. The default table name
is still `opentelemetry_traces`. V2 uses the same trace-ID partitioning, skipping
indexes on `service_name`, `trace_id`, and `parent_span_id`, append-only mode,
and auxiliary service/operation tables described below.
The table is created automatically on the first write. By default, trace data is
stored in `opentelemetry_traces`; set the `x-greptime-trace-table-name` header in
OTLP/HTTP requests to customize the table name. V2 uses the trace-ID partitioning,
skipping indexes on `service_name`, `trace_id`, and `parent_span_id`, append-only
mode, and auxiliary service/operation tables described below.

Use a new table when switching from v1 to v2. Changing the pipeline header does
not migrate existing data: writes using v2 are rejected for a table marked as
Expand Down Expand Up @@ -224,11 +226,11 @@ Create Table | CREATE TABLE IF NOT EXISTS "opentelemetry_traces" (

## Shared Table Behavior

The following behavior applies to both v1 and v2.
The following behavior applies to both v2 and v1.

### Column storage options

New v1 and v2 trace tables created automatically through OTLP use these column options:
New v2 and v1 trace tables created automatically through OTLP use these column options:

- `span_id` and `parent_span_id`: `encoding='plain'` and `page_size='64KiB'`.
- `timestamp_end`: `encoding='delta_binary_packed'`.
Expand Down
Loading
Loading