Observability Fundamentals

What Is an Observability API? Endpoints, Authentication, and Queries for SREs

November 21, 2026
7
min read
Observability Fundamentals

An observability API gives scripts access to an observability platform’s data and configuration. If a service starts returning HTTP 5xx errors, you can use its query endpoints to retrieve error-rate metrics, search related logs, and inspect available traces without repeating those searches in the UI. Other endpoints can ingest telemetry or create and update resources such as monitors, dashboards, and access policies.

To use an observability API, you need to know which endpoint accepts your request, what permissions it requires, and how to interpret the response. This guide walks through an authenticated telemetry query, then explains pagination, errors, exporting results, and connecting compatible endpoints to Grafana.

What Is an Observability API?

An observability API is the interface through which applications, scripts, and external tools communicate with an observability platform programmatically. It lets them retrieve telemetry, send new data, or manage platform configuration without relying on the graphical interface. Depending on the platform, these capabilities are exposed through different interfaces and protocols:

  • REST APIs: Expose resources and operations through HTTP methods such as GET and POST, commonly using JSON for request and response bodies. groundcover uses REST endpoints such as POST /api/logs/v2/search to retrieve logs using gcQL.
  • GraphQL APIs: Let clients request specific fields through a defined schema. New Relic’s NerdGraph uses GraphQL to query observability data and manage platform resources, while telemetry ingestion uses separate APIs.
  • Telemetry ingestion protocols: OTLP and Prometheus remote write send telemetry to a backend rather than providing an interface for querying stored data.

An observability API is different from API observability. API observability is the practice of monitoring your application’s APIs, including their latency, error rates, throughput, and dependencies. An observability API provides programmatic access to the telemetry and platform resources used to investigate that behavior.

How Does an Observability API Work?

An observability API lets clients retrieve telemetry from a backend or change its configuration through authenticated requests. For a query to return useful results, the telemetry must first be collected, processed, and stored:

  1. Applications and infrastructure generate metrics, logs, and traces through instrumentation such as OpenTelemetry SDKs or collection methods such as eBPF.
  2. Collectors and sensors forward that telemetry to a backend using protocols such as OTLP or Prometheus remote write.
  3. The backend processes and stores the data. In groundcover, ClickHouse stores logs, traces, and Kubernetes events, while VictoriaMetrics stores metrics.
  4. A client sends an authenticated query request with the required expression and time parameters. The backend evaluates the request and returns results in the endpoint’s response format.

Query APIs can use the same query languages as the platform’s UI. For example, groundcover supports gcQL and MetricsQL through its Data Explorer and API, allowing you to reuse query expressions in scripts and incident workflows.

Telemetry Ingestion, Query, and Management APIs

Observability platforms expose three main categories of APIs, each serving a different purpose.

CategoryPurposeExamples
IngestionReceives telemetry from applications, collectors, and sensorsOTLP, Prometheus remote write
QueryRetrieves and analyzes stored telemetryPrometheus HTTP API, groundcover gcQL search
ManagementCreates and updates platform resourcesDashboards, monitors, integrations, access policies

Ingestion APIs receive telemetry before it becomes available for querying. OTLP commonly uses port 4317 for gRPC and 4318 for HTTP. OTLP/HTTP sends traces, metrics, and logs through /v1/traces, /v1/metrics, and /v1/logs, using Protobuf or its JSON encoding. Prometheus remote write sends metrics to compatible receivers. These protocols deliver telemetry but do not provide interfaces for querying stored results.

Query APIs retrieve telemetry using expressions, filters, and time parameters. Prometheus-compatible endpoints evaluate metric queries at a specific point in time or across a time range. In groundcover, POST /api/logs/v2/search accepts a gcQL expression with start and end timestamps, while metrics endpoints accept MetricsQL expressions. The response format depends on the endpoint and query type.

Management APIs operate on platform resources rather than telemetry records. They allow you to create dashboards, update monitors, configure integrations, and manage access policies. These operations have their own permission requirements. For example, groundcover allows users with Viewer permissions to read monitor definitions, while creating or updating monitors requires Editor permissions or higher.

In groundcover, ingestion and querying use different endpoints and credentials. A BYOC backend receives OTLP/HTTP traces at https://{BYOC_ENDPOINT}/v1/traces and Prometheus remote write at https://{BYOC_ENDPOINT}/api/v1/write, using an ingestion key. Query and management requests use https://api.groundcover.com with a service-account API key. Self-hosted deployments use their configured API URL.

API Resources, Endpoints, and HTTP Methods

An observability API organizes operations around resources such as metrics, logs, traces, monitors, dashboards, and integrations. Each endpoint combines a base URL with a resource path and defines the supported HTTP methods, parameters, permissions, and response format.

For example, groundcover’s API base URL is https://api.groundcover.com. The /api/logs/v2/search endpoint returns an array of matching log records, while /api/logs/v3/search returns a JSON object containing data and valueFieldHints. Your client must parse the response format associated with the selected endpoint version.

Beyond telemetry, observability platforms may expose resources that define data sources, organizational boundaries, and monitored infrastructure:

  • Workspaces: Organize access to observability data and resources. Some APIs expose workspaces as REST resources with operations for listing available workspaces and retrieving a specific workspace by ID. These operations are not standardized. In groundcover, the MCP Server exposes list_workspaces, while REST requests select the relevant backend using X-Backend-Id when required.
  • Technology integrations: Connect the platform to external systems or data sources. groundcover supports data integrations for collecting information from external technologies and Destinations for sending notifications to other services. The available listing, retrieval, and configuration operations depend on the integration type.
  • Source subscriptions: Some platforms use this term for configurations that associate telemetry sources with a particular subscription or data scope. The resource structure and query operations are vendor-specific; there is no standard source-subscription API shared by observability platforms.
  • Assets and technology instances: Represent monitored infrastructure and applications, such as hosts, Kubernetes workloads, databases, and services. Where an API exposes infrastructure inventory, you can retrieve these entities and their metadata to associate telemetry with the resources that produced it.

The following groundcover endpoints illustrate how HTTP methods map to observability operations:

OperationMethod and endpoint
Query instant metricsGET /api/prometheus/api/v1/query
Query metrics over a rangePOST /api/metrics/query-range
Search logsPOST /api/logs/v2/search
Search monitor definitionsPOST /api/v2/monitors/search
List dashboardsGET /api/dashboards
Create a monitorPOST /api/v2/monitors
Update a storage policyPUT /api/storage-management/{data_type}
Delete a monitorDELETE /api/v2/monitors/{uuid}

GET retrieves resources or query results, while PUT updates existing resources and DELETE removes them. POST can submit a read-only search or create a resource. For example, POST /api/logs/v2/search retrieves matching logs without changing stored data, whereas POST /api/v2/monitors creates a monitor.

This distinction matters when retrying requests. A read-only POST search can be retried without creating duplicate resources, but repeating a resource-creation request can create another resource if the first attempt succeeded. Prometheus also accepts form-encoded POST requests for queries that would otherwise exceed URL length limits.

Authentication and Authorization

Observability APIs use authentication credentials to identify the requesting client and authorization rules to determine which operations it can perform. In groundcover, requests use an API key as a bearer token in the Authorization header.

A groundcover API key belongs to a service account and inherits its role-based access control (RBAC) permissions. A key can be restricted to a subset of the account’s policies, but it cannot grant permissions beyond those assigned to the service account. Only Admins can create or revoke API keys, and the key value is shown once when created.

Send the key as Authorization: Bearer <API_KEY>. Include X-Backend-Id for operations requiring backend context, especially when your account contains multiple backends. You can find the backend ID under Settings → Access → API Keys.

Ingestion keys and API keys have different purposes:

AttributeIngestion KeyAPI Key
PurposeSends telemetry to the backendQueries data and manages resources
PermissionsWrite-only, with optional remote-configuration readInherits service-account RBAC
VisibilityCan be revealed after creationShown once
RevocationStops authenticated telemetry ingestionPrevents further authenticated API calls

An ingestion key cannot retrieve logs or create dashboards through groundcover’s query and management APIs. Those operations require an API key with the appropriate permissions.

Scope credentials to the operations they perform. A script investigating errors in one Kubernetes namespace, for example, should use a service account with read permissions limited to the required data scope. Store keys in a secrets manager, keep them out of source control, rotate them, and revoke credentials that are no longer needed.

Authentication and authorization failures require different fixes. A 401 Unauthorized response indicates missing or invalid authentication credentials, so check the key, request header, and issuing environment. A 403 Forbidden response means the server refuses the operation, potentially because the credential lacks the required RBAC permissions or access to the requested resource. Check the credential’s role and data scope before retrying.

What Can You Do With an Observability API?

Observability APIs let you automate recurring investigations, retrieve operational data, and manage monitoring configuration without performing each task manually.

  • Track application performance: Query request counts, error rates, and latency percentiles across a defined time range. Compare results before and after a deployment to identify performance regressions.
  • Investigate application failures: Search error logs by workload and namespace, then query traces for failed HTTP requests and slow operations. Use the results to identify affected services and narrow the investigation.
  • Inspect Kubernetes workloads: Retrieve the current state of Pods, Deployments, and Nodes through infrastructure entity queries. Search historical Kubernetes events for failed scheduling, container restarts, and other warnings.
  • Generate reliability reports: Retrieve request totals, error counts, and latency measurements through APM queries. Use consistent time windows to calculate service-level indicators (SLIs) and track error-budget consumption against defined service-level objectives (SLOs).
  • Manage monitoring configuration: Create and update dashboards, monitors, and access policies through management APIs or Terraform. Store configurations in version control so changes can be reviewed and applied across environments.
  • Integrate with incident workflows: Configure Notification Routes and Destinations to deliver monitor notifications to tools such as Slack and PagerDuty. Scripts can retrieve supporting telemetry when an incident occurs, while the groundcover MCP Server makes observability data accessible to compatible AI agents.

Querying Observability Data Through an API

Querying observability data through an API involves authenticating the request, specifying the data and time range, and interpreting the response. The following example uses groundcover to demonstrate the process with an error-log query.

Step 1: Prepare Your API Credentials

Start by obtaining a credential with permission to read the telemetry you need. Check whether the API requires a specific backend, workspace, or project identifier to select the correct data source.

For this example, create a groundcover API key under Settings → Access → API Keys. An Admin must assign the key to a service account with the appropriate read permissions. Store it securely because groundcover displays the value only once. If your account has multiple backends, copy the backend ID from the same page.

Step 2: Send an API Query

Choose an endpoint for the telemetry type you want to retrieve and supply the required filters, time range, and authentication headers.

For logs, groundcover provides POST /api/logs/v2/search. Its JSON request body requires start and end timestamps in RFC3339 format and a query containing gcQL.

Run the following command to retrieve up to 20 error logs, sorted from newest to oldest:

curl --request POST 'https://api.groundcover.com/api/logs/v2/search' \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
    "start": "2026-08-22T14:00:00Z",
    "end": "2026-08-22T15:00:00Z",
    "query": "level:error | sort by (_time desc) | fields _time, workload, namespace, content | limit 20"
  }'

Replace the timestamps with your investigation window. For accounts with multiple backends, add -H 'X-Backend-Id: <YOUR_BACKEND_ID>' to select the correct backend.

Step 3: Interpret the API Response

Check the response structure before processing the returned data. Observability APIs may return records directly in a JSON array or wrap them in an object containing results and metadata.

groundcover’s v2 log-search endpoint returns a JSON array. For example:

[
  {
    "_time": "2026-08-22T14:50:56.503949956Z",
    "workload": "checkout-service",
    "namespace": "production",
    "content": "failed to process payment: connection timeout"
  }
]

Read _time to identify when the error occurred, workload and namespace to locate its Kubernetes source, and content to examine the error message.

Here, checkout-service recorded a payment connection timeout. The log identifies a failure, but you need additional queries to determine its frequency and cause.

Step 4: Refine the Query

Use the initial results to narrow your investigation or aggregate records. Rather than retrieving every matching log and counting errors locally, let the backend perform the aggregation.

For example, replace the query value in the original request with:

level:error | stats by (workload) count() as errors | sort by (errors desc) | limit 10

Keep the same time range. The query groups matching error logs by workload and sorts them by count.

Compare the results to identify which workloads produce the most errors. Then narrow subsequent queries to the affected workload and namespace to investigate the underlying failure.

Querying Metrics and Traces

You can apply the same request-and-response process to metrics and traces, although their endpoints and query formats differ.

Metrics: Use a range query to retrieve measurements across a defined period. Supply a metric expression, start and end timestamps, and a resolution step. For example, groundcover’s POST /api/metrics/query-range endpoint accepts MetricsQL and returns timestamped values for each matching series.

To check CPU usage during the same investigation window, run:

curl --request POST 'https://api.groundcover.com/api/metrics/query-range' \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
    "promql": "avg(groundcover_cpu_usage_percent) by (cluster)",
    "start": "2026-08-22T14:00:00Z",
    "end": "2026-08-22T15:00:00Z",
    "step": "1m"
  }'

Add X-Backend-Id when required. The response contains a velocities array with timestamps, values, and metric labels. Compare the measurements with the error timeline to check for resource pressure, without assuming that elevated CPU usage caused the failure.

Traces: Query spans to examine individual operations, their durations, and error status. Filter by the affected service and time range to narrow the results.

In groundcover, use POST /api/traces/v2/search with the same JSON request structure as the log query. For example, replace the endpoint and query value to retrieve failed HTTP spans from checkout-service:

workload:checkout-service span_type:http status_code>=500 | sort by (_time desc) | fields _time, resource, status_code, duration_seconds | limit 20

Inspect the returned operations and durations to identify failing routes and slow requests. Keep workload and time filters consistent across telemetry queries wherever the API supports them.

Handling Pagination and API Errors

Pagination

When an API limits the number of records returned per request, use its pagination mechanism to retrieve subsequent batches. This may involve offsets, cursors, or page tokens, depending on the API.

groundcover’s gcQL log searches use offset and limit. The earlier request retrieves up to 20 records. To request the next 20, keep the same endpoint, time range, and sorting expression, but change the query to include offset 20:

curl --request POST 'https://api.groundcover.com/api/logs/v2/search' \
  -H 'Authorization: Bearer <YOUR_API_KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{
    "start": "2026-08-22T14:00:00Z",
    "end": "2026-08-22T15:00:00Z",
    "query": "level:error | sort by (_time desc) | fields _time, workload, namespace, content | offset 20 | limit 20"
  }'

For the third page, change offset 20 to offset 40. Continue until the API returns fewer than 20 records.

Use fixed timestamps and a stable sort order across pages. Offset pagination does not guarantee an immutable snapshot, so late-arriving records can shift page boundaries. Deduplicate results using stable record identifiers when available.

To save query results for external analysis, add --output error-logs.json to the earlier cURL request. This writes that page’s JSON response to a local file; retrieve additional pages separately if you need the complete result set.

Rate Limits and API Errors

Check an API’s rate limits before running repeated queries or automated exports. groundcover permits up to 150 requests per second and 1,000 per minute per API key.

When a request fails, inspect its HTTP status and response body to determine the cause.

StatusLikely CauseCorrective ActionRetry Unchanged?
400Invalid query, missing parameters, or malformed requestCorrect the query or request bodyNo
401Missing or invalid authentication credentialsVerify the API key and authentication headerNo
403Insufficient permissionsCheck the service account’s RBAC policiesNo
404Incorrect endpoint or unsupported resourceVerify the URL and backend capabilityNo
429Request rate exceeds the limitReduce concurrency and use backoffAfter waiting
5xxServer-side failureRetry transient failures with bounded backoffFor read-only queries

For 429 responses, honor Retry-After when present and use exponential backoff with jitter to avoid repeated request bursts. Set a client-side timeout for each attempt.

Before retrying a request that creates or modifies a resource, check whether the original operation succeeded. A timeout does not necessarily mean the server failed to process the request.

Using Observability APIs With OpenTelemetry, Prometheus, and Grafana

OpenTelemetry, Prometheus, and Grafana connect to different stages of an observability workflow. OpenTelemetry sends telemetry to a backend, Prometheus-compatible APIs retrieve stored metrics, and Grafana queries those APIs to visualize the results.

OpenTelemetry: Sending Telemetry to a Backend

OpenTelemetry SDKs and Collectors export metrics, logs, and traces through the OpenTelemetry Protocol (OTLP). OTLP supports HTTP and gRPC, but it handles telemetry delivery rather than querying historical records.

For example, applications running in Kubernetes can send OTLP/HTTP data to groundcover’s in-cluster sensor at groundcover-sensor.groundcover.svc.cluster.local:4318. Collectors outside the cluster can send data to a BYOC ingestion endpoint over HTTPS or gRPCS on port 443, using an ingestion key.

Once the backend stores the telemetry, you retrieve it through the appropriate query API rather than the OTLP ingestion endpoint.

Prometheus: Querying Stored Metrics

Prometheus-compatible HTTP APIs let you retrieve metrics without accessing the underlying storage directly. Two endpoints handle common query operations:

  • /api/v1/query: Evaluates a PromQL expression at a specific point in time.
  • /api/v1/query_range: Evaluates an expression across a time range using start, end, and step parameters.

Both return JSON containing a status field and a data object with the query results. Prometheus remote write serves a different purpose: it sends metrics to a backend rather than retrieving them.

For example, groundcover supports PromQL-compatible MetricsQL expressions through its metrics API. You can retrieve metrics through its Prometheus-compatible interface or use its JSON query endpoints, accounting for their different response structures.

Grafana: Visualizing API Query Results

Grafana uses data sources to query observability backends and display the results in dashboards. Its built-in Prometheus data source works with compatible metrics-query APIs, so you do not need to export metrics into files before visualizing them.

To connect a compatible backend:

  1. Open Connections → Add new connection in Grafana and select the Prometheus data source.
  2. Enter the backend’s Prometheus-compatible URL. For a supported groundcover BYOC connection, use https://app.groundcover.com/api/prometheus.
  3. Configure the authentication method required by your backend’s Prometheus-compatible endpoint.
  4. Click Save & test, then create a dashboard panel using a metric available in your backend.

For example, if your application exposes http_requests_total, enter this PromQL expression to chart its request rate:

sum(rate(http_requests_total[5m]))

Grafana sends the query to the configured backend when the panel refreshes. It can also evaluate metric queries for alerting.

This integration works through the Prometheus-compatible API, not an arbitrary REST endpoint. If you need to process logs, traces, or custom JSON responses, use an appropriate data source or query those APIs directly from your application.

How AI Agents Use Observability APIs

AI agents use observability APIs to query production telemetry, investigate incidents, and generate monitoring configurations. Instead of executing a fixed sequence of requests, they can select tools and adjust queries based on the data they retrieve.

Querying Telemetry Through APIs and MCP

AI agents can send authenticated REST API requests directly or use the Model Context Protocol (MCP) to access observability tools. MCP gives compatible AI clients a standard interface for interacting with external systems.

For example, the groundcover MCP Server exposes query_metrics, query_logs, query_traces, query_events, and query_entities to agents in Cursor, Claude Code, and other MCP clients. An agent selects a tool, supplies the relevant filters and time range, and processes the returned telemetry to answer questions about application performance or infrastructure health.

Investigating Incidents Across Telemetry Signals

The agent can use query_issues to inspect firing monitors, query_metrics to examine error rates, and query_logs to find matching application errors. It can then run query_traces to inspect failed requests and query_entities to check the current Kubernetes deployment state.

Each result helps the agent narrow the next query, moving from an error spike to the affected requests and potential causes. Verify its conclusions against the underlying telemetry before acting on them.

Generating Dashboards and Monitors

AI agents can also use observability data to prepare monitoring configurations. For example, an agent investigating checkout errors can identify relevant metrics, select suitable queries, and draft a dashboard showing request rates, error counts, and p95 latency.

The groundcover MCP Server provides async_generate_dashboard and async_generate_monitor for these tasks. The tools generate dashboard JSON or monitor YAML from natural-language requests. They return drafts rather than creating resources automatically, allowing you to review the configuration before applying it through an API or Terraform.

groundcover also provides Agent Mode, a built-in assistant for investigating issues, exploring telemetry, and drafting dashboards or monitors. The MCP Server connects external AI agents, while Agent Mode provides these capabilities within the groundcover platform.

FAQs

An observability API gives applications and scripts programmatic access to telemetry and monitoring configurations. API observability focuses on monitoring your application’s APIs, including their latency, error rates, throughput, and dependencies. You can use an observability API to retrieve the metrics and traces needed to investigate API performance.

Yes. Open-source tools such as Prometheus provide APIs without software licensing fees. You can query metrics through the Prometheus HTTP API for free, although you still need infrastructure and storage to run the software.

Use your observability platform’s workspace-listing API to retrieve accessible metric workspaces, then its workspace-detail operation to fetch one by ID. Endpoints vary by platform. In groundcover, you can select workspaces through the console or use the MCP Server’s list_workspaces tool to retrieve tenant UUIDs and backend IDs. For REST queries, use X-Backend-Id to select the relevant backend when required.

Source subscriptions identify telemetry sources configured for monitoring, while technology integrations connect observability platforms to external systems. Their resource definitions vary by provider. In groundcover, use GET /api/integrations/v1/data/config to list data integration configurations and GET /api/integrations/v1/data/config/{type}/{id} to retrieve one. Other platforms may expose operations named listIntegrations and getIntegrationById, alongside separate APIs for source subscriptions.

Yes. Query APIs can retrieve stored telemetry in batches using pagination, subject to rate limits and result-size restrictions. For continuous high-volume delivery, configure a telemetry pipeline using protocols such as OTLP or Prometheus remote write to send data to the required destination as it is collected.

Sign up for Updates

Keep up with all things cloud-native observability.

We care about data. Check out our privacy policy.