> 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/raw-prometheus-and-clickhouse.md).

# Metrics and Logs API

This page describes the available API endpoints for querying logs, traces, Kubernetes events, and metrics in groundcover, including how to authenticate and structure requests for general data retrieva

## Authentication

Authentication is performed using an API key generated in the [API Keys section](/administer/api-keys.md) of the groundcover console.

All API requests must include the API key in the Authorization header using the following format:

```
Authorization: Bearer <YOUR_API_KEY>
```

{% hint style="info" %}
Self-hosted ([onPrem](/architecture/overview.md#onprem) / [airGapped](/architecture/overview.md#airgapped)) deployments use their own API URL. Replace the `groundcover.com` hosts below with your environment's endpoint, and use an API key generated in that environment's console - API keys are only valid for the environment that issued them.
{% endhint %}

## Rate Limits

groundcover APIs enforce rate limits on a per-client basis to ensure fair usage and system stability. Each client is allowed up to **150 requests per second and 1,000 requests per minute**. A “client” is identified by the Authorization header, which typically represents an API key. This means that rate limits are applied independently for each API key used

## Raw Prometheus API for Metrics

Use the following endpoint to query the groundcover Prometheus API:

```bash
https://app.groundcover.com/api/prometheus/api/v1/query
```

To see usage example on how to query metrics in groundcover see: [Query metrics examples](/reference/remote-access-and-apis/api-examples/query-metrics.md)

For a complete Prometheus REST API documentation, and available operations, see: [Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/)

## Logs, Traces & Events API (gcQL)

Logs, traces, and Kubernetes events are queried with [gcQL](/investigate/querying-your-groundcover-data/groundcover-query-language.md) through the search endpoints:

```bash
https://api.groundcover.com/api/logs/v2/search
https://api.groundcover.com/api/traces/v2/search
https://api.groundcover.com/api/k8s/v2/events/search
```

For usage examples see: [Query Data with gcQL](/reference/remote-access-and-apis/api-examples/query-data-gcql.md)

## Legacy API (Clickhouse)

The following configurations are deprecated but may still be in use in older setups.

{% hint style="warning" %}
The legacy datasources is using a different API key than described above. The API key can be obtained by running: `groundcover auth get-datasources-api-key`
{% endhint %}

You can query the legacy API to execute SQL statements directly on the Clickhouse database.

Try the following structure:

```bash
curl https://ds.groundcover.com/ \
    -H "X-ClickHouse-Key: <DS-API-KEY-VALUE>" \
    --data "SELECT count() FROM logs LIMIT 1 FORMAT JSON" 
```


---

# 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/raw-prometheus-and-clickhouse.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.
