> 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/log-pipelines-api.md).

# Log 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.

### Endpoints

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

### Read configuration

```bash
curl --request GET 'https://api.groundcover.com/api/pipelines/logs/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 saved configuration text as a JSON string. Use `jq -r '.value'` to decode and display it as shown in [Get Logs Pipeline Configuration](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/get-logs-pipeline-configuration.md#response). If there is no configuration, the endpoint returns HTTP 204 with no body.

### Create or replace configuration

Both POST and PUT accept a JSON request body with a required `value` string. That string contains the pipeline configuration document, which can be YAML or JSON text. 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.

The file-based examples below require `jq`. Save this configuration in `logs-pipeline.yaml`:

```bash
cat > logs-pipeline.yaml <<'YAML'
ottlRules:
  - ruleName: add_environment_tag
    statements:
      - set(attributes["environment"], "production")
YAML
```

This rule adds `environment: production` to each log's attributes. Adapt it to your environment and include any existing rules you want to keep.

Wrap the file contents in the JSON `value` field:

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

`jq --rawfile` reads the file as a string and handles JSON escaping for you. `--data-binary @-` sends the generated JSON from standard input. If the file contains JSON configuration text instead of YAML, use the same command with that filename; `value` is still a string.

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. Despite its name, `ruleYaml` accepts the same YAML or JSON configuration text as `value`. Reuse the `logs-pipeline.yaml` file above and provide a sample log record:

```bash
jq -n --rawfile ruleYaml logs-pipeline.yaml '{
  ruleYaml: $ruleYaml,
  logRecord: {
    body: "Payment processed successfully",
    level: "info",
    attributes: {payment_id: "payment-1234"},
    tags: {}
  }
}' | \
  curl --fail-with-body --request POST \
    'https://api.groundcover.com/api/pipelines/logs/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`, `logDropped`, an optional `error`, and the resulting `logRecord`. The input record can include `time` (RFC3339), `source`, `cluster`, `env`, `workload`, `namespace`, `container_name`, `body`, `trace_id`, `span_id`, `level`, `format`, `attributes`, and `tags`.

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.

For this example, a successful simulation preserves `payment_id` and adds the environment attribute. The returned `logRecord.attributes` contains:

```json
{
  "payment_id": "payment-1234",
  "environment": "production"
}
```

### 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/logs/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/logs/current-stats` without `configId`. Its response contains both `stats` and `totalStats`.

### Clear configuration

```bash
curl --request DELETE 'https://api.groundcover.com/api/pipelines/logs/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

* [Get Logs Pipeline Configuration](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/get-logs-pipeline-configuration.md)
* [Update Logs Pipeline Configuration](https://docs.groundcover.com/reference/remote-access-and-apis/api-examples/update-logs-pipeline-configuration.md)
* [Log Pipelines](https://docs.groundcover.com/collect-data/data-pipelines/log-pipelines.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/log-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.
