> For the complete documentation index, see [llms.txt](https://docs.groundcover.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/trace-pipelines-api.md).

# Trace Pipelines API

Manage pipeline rules, simulate transformations, and inspect processing statistics.

### Authentication and permissions

Use an [API key](https://docs.groundcover.com/administer/api-keys.md) in `Authorization: Bearer <YOUR_API_KEY>` and select the backend with `X-Backend-Id: <YOUR_BACKEND_ID>`. Use your own API base URL for a self-hosted deployment.

**Admin required:** creating, replacing or clearing the pipeline configuration. Reading configuration, simulating rules and querying statistics require backend access but do not require Admin permissions.

The configuration and simulation examples use `jq`; install it before running them. It builds the JSON request body from a readable configuration file.

### Endpoints

| Method | Endpoint                              | Purpose                                                           |
| ------ | ------------------------------------- | ----------------------------------------------------------------- |
| GET    | `/api/pipelines/traces/config`        | Read the current configuration.                                   |
| POST   | `/api/pipelines/traces/config`        | **Admin required.** Write configuration; returns HTTP 201.        |
| PUT    | `/api/pipelines/traces/config`        | **Admin required.** Replace configuration; returns HTTP 200.      |
| DELETE | `/api/pipelines/traces/config`        | **Admin required.** Clear the configured rules; returns HTTP 200. |
| POST   | `/api/pipelines/traces/simulate`      | Test rules against a supplied record without saving.              |
| POST   | `/api/pipelines/traces/stats`         | Query processing statistics, optionally for a configuration ID.   |
| POST   | `/api/pipelines/traces/current-stats` | Query statistics for the current pipeline.                        |

### Read configuration

```bash
curl --request GET 'https://api.groundcover.com/api/pipelines/traces/config' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'X-Backend-Id: <YOUR_BACKEND_ID>'
```

The response contains `uuid`, `created_by`, `created_timestamp`, and `value`. `value` is the configuration text, not a nested JSON object. If there is no configuration, the endpoint returns HTTP 204 with no body.

For a readable view of a saved configuration, append `| jq -r '.value'` to the GET command. This prints the string with its original line breaks.

### Create or replace configuration

Both POST and PUT require an **outer JSON request body** with a `value` string. The server parses that string as YAML; JSON configuration text is also accepted by this parser. Rule names must be nonempty and unique. Unknown configuration fields and invalid OTTL statements are rejected with HTTP 400.

Read and save the current configuration before replacing it. A write replaces the complete rule list; it does not append or merge individual rules. Preserve any existing rules you want to keep.

```bash
cat > trace-pipeline.yaml <<'YAML'
ottlRules:
  - ruleName: normalize_span_name
    statements:
      - set(span_name, "example-operation")
YAML

jq -n --rawfile value trace-pipeline.yaml '{value: $value}' |
curl --request PUT 'https://api.groundcover.com/api/pipelines/traces/config' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'X-Backend-Id: <YOUR_BACKEND_ID>' \
  --header 'Content-Type: application/json' \
  --data-binary @-
```

Use POST with the same body to write configuration with a 201 response. Successful writes return the same metadata and `value` structure as GET.

### Simulate rules

Simulation does not modify the saved pipeline. Its outer request body is JSON, and `ruleYaml` is a string parsed in the same YAML or JSON rule-list format as `value` above. Reuse `trace-pipeline.yaml` from the previous example:

```bash
jq -n --rawfile ruleYaml trace-pipeline.yaml '{
  ruleYaml: $ruleYaml,
  span: {
    span_name: "original-operation",
    status: "ok",
    attributes: {},
    tags: {}
  }
}' |
curl --request POST 'https://api.groundcover.com/api/pipelines/traces/simulate' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'X-Backend-Id: <YOUR_BACKEND_ID>' \
  --header 'Content-Type: application/json' \
  --data-binary @-
```

The response includes `ruleValid`, `ruleRan`, `spanDropped`, an optional `error`, and the resulting `spanRecord`. The input `span` can include `trace_id`, `span_id`, `parent_id`, infrastructure fields, `span_name`, `kind`, `status`, `start_time`, `end_time`, `request_body`, `response_body`, `request_headers`, `response_headers`, `query_parameters`, `attributes`, and `tags`. Timestamps use RFC3339; nonempty trace and span IDs must be valid hexadecimal IDs.

HTTP 200 alone does not mean the rule is valid or executed successfully: inspect `ruleValid` and `error`. A condition that does not match can leave `ruleRan` false.

### Query statistics

| Field      | Type   | Required | Description                                                          |
| ---------- | ------ | -------- | -------------------------------------------------------------------- |
| `start`    | string | Yes      | RFC3339 start time.                                                  |
| `end`      | string | Yes      | RFC3339 end time, at or after `start`.                               |
| `sources`  | array  | No       | Structured source filter conditions. Omit for all permitted sources. |
| `configId` | string | No       | Configuration fingerprint (`uuid` from GET). Only for `/stats`.      |

```bash
curl --request POST 'https://api.groundcover.com/api/pipelines/traces/stats' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'X-Backend-Id: <YOUR_BACKEND_ID>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start": "2026-10-28T10:00:00Z",
  "end": "2026-10-28T11:00:00Z",
  "configId": "<CONFIGURATION_UUID>"
}'
```

The response is `{"stats": [...]}`. Each entry identifies the configuration and rule and includes processed/dropped counts, condition and execution errors, and processing-time measurements. The shared response uses names such as `totalLogsSeen` and `totalLogsDropped`, including for trace pipelines.

For the current configuration, send the same time window to `/api/pipelines/traces/current-stats` without `configId`. Its response contains both `stats` and `totalStats`.

### Clear configuration

```bash
curl --request DELETE 'https://api.groundcover.com/api/pipelines/traces/config' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'X-Backend-Id: <YOUR_BACKEND_ID>'
```

This clears the dynamic pipeline configuration. It does not delete stored observability data. An unavailable configuration service can return HTTP 503.

### Related documentation

* [Traces Pipeline](https://docs.groundcover.com/collect-data/data-pipelines/traces-pipeline.md)
* [Log Pipelines API](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/log-pipelines-api.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/trace-pipelines-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
