Skip to content

Traces, metrics and logs in your own tool

How-to guideThe steps for one task.

In Apinx Cloud, on the Enterprise plan, your organization can send what happens to its requests to the monitoring tool you already use, such as Grafana, Datadog or any tool that speaks OpenTelemetry:

  • Traces: one per request, with every policy step and backend attempt.
  • Metrics: requests, errors and latency, once a minute.
  • Request logs: one line per request (sampled by default).

All three go to one address, your OpenTelemetry collector, with one token. This page sets them up in five steps. The details of what each one carries are in Observability.

What you need

  • An OpenTelemetry collector reachable from the internet over TLS, for example https://otel.example.com (HTTP) or otel.example.com:4317 (gRPC).
  • The token your collector expects, if it asks for one.
  • An administrator or editor role in your organization.

1. Open Admin › Observability

In the console, choose Admin in the menu on the left, then the Observability tab. The card you need is Traces in your own tool, below Request tracing.

The Observability tab under Admin in the Apinx console

2. Fill in the card

The Traces in your own tool card with traces, metrics and request logs turned on

Field What to put
Export traces to my collector Tick it. It turns the export on; the other two choices need it.
Send metrics Tick it to send requests, errors and latency every minute.
Send request logs Sampled is a good start: every error, and 1 in 100 other requests. Errors only or Every request if you prefer.
Include caller IP and user agent Leave it off unless you need them: they are personal data.
Protocol HTTP for an https:// address, gRPC for host:port.
Collector Your collector's address, for example https://otel.example.com. Apinx adds /v1/traces, /v1/metrics and /v1/logs itself; if you paste an address ending in /v1/traces, that works too.
Authorization Your collector's token. A token on its own is sent as Bearer <token>; write Basic … or another scheme in full. It is stored encrypted and never shown again.
Sampling (%) The share of requests whose traces are sent. 100 sends all of them.
Extra headers Only when your collector wants one, such as X-Scope-OrgID: acme.

3. Save and check

Press Save. Under the button, the card shows one line per signal: how much has been sent since the server started, and any error.

The card after saving, with a status line for traces, metrics and request logs

Send a few requests through your API and open the page again: the numbers start to count.

The card says What it means What to do
401 Unauthorized Your collector refused the token. Type the token again in Authorization and save.
connection refused or no such host Apinx cannot reach the address. Check the address and that the collector is reachable from the internet.
Paused after 10 minutes of failures Every send failed for 10 minutes, so Apinx waits an hour before it tries again. Fix the cause. Apinx tries again by itself within the hour; to retry at once, change the collector address, protocol, token or headers and save.
lines dropped Request logs arrived faster than 2,000 a second, or the collector was paused. Choose Sampled or Errors only.

4. Set up your collector

Your collector receives the three signals and forwards each one to its store. This is a complete OpenTelemetry Collector configuration for Grafana's stack: Tempo for traces, Prometheus for metrics, Loki for logs. Change the addresses to yours.

extensions:
  bearertokenauth:            # checks the token Apinx sends (contrib build of the collector)
    token: ${env:APINX_OTEL_TOKEN}

receivers:
  otlp:
    protocols:
      http:
        endpoint: 0.0.0.0:4318
        auth: { authenticator: bearertokenauth }
      grpc:
        endpoint: 0.0.0.0:4317
        auth: { authenticator: bearertokenauth }

processors:
  batch: {}

exporters:
  otlp/tempo:                 # traces
    endpoint: tempo:4317
    tls: { insecure: true }
  otlphttp/prometheus:        # metrics, into Prometheus's own OTLP endpoint
    endpoint: http://prometheus:9090/api/v1/otlp
  otlphttp/loki:              # request logs, into Loki's own OTLP endpoint
    endpoint: http://loki:3100/otlp

service:
  extensions: [bearertokenauth]
  pipelines:
    traces:  { receivers: [otlp], processors: [batch], exporters: [otlp/tempo] }
    metrics: { receivers: [otlp], processors: [batch], exporters: [otlphttp/prometheus] }
    logs:    { receivers: [otlp], processors: [batch], exporters: [otlphttp/loki] }

Prometheus takes the metrics on its OTLP endpoint when it runs with --web.enable-otlp-receiver (Prometheus 3). To keep your organization's name on every series, add this to prometheus.yml:

otlp:
  promote_resource_attributes: [apinx.organization]

Loki 3 takes the logs on /otlp as they are, with its default settings (the v13 schema and structured metadata on). Tempo takes the traces on its OTLP port.

5. See it in Grafana

Metrics, in Prometheus

In Grafana, choose Explore, pick Prometheus, switch the editor to Code, paste a query and press Run query.

Grafana Explore with a Prometheus query on apinx_requests_total

To see Query
Requests per second, by status class sum by (status_class) (rate(apinx_requests_total[5m]))
Error rate sum(rate(apinx_errors_total[5m])) / sum(rate(apinx_requests_total[5m]))
Slowest routes (p95) histogram_quantile(0.95, sum by (le, route) (rate(apinx_request_duration_seconds_bucket[5m])))
Requests per calling application, last hour sum by (application) (increase(apinx_requests_total[1h]))
One API only add {api="orders"} after the metric name, e.g. rate(apinx_requests_total{api="orders"}[5m])

The metrics are sent once a minute, so use windows of [5m] or more; the first numbers appear about two minutes after you save.

Traces, in Tempo

Explore › Tempo › Search, or write TraceQL in TraceQL:

To find TraceQL
Failed requests {resource.service.name="apinx" && span.http.response.status_code >= 500}
Requests slower than one second {resource.service.name="apinx" && duration > 1s}
One route {span.apinx.route="orders-get-order"}

Open a trace to see each policy step and each backend attempt with its time.

Request logs, in Loki

Explore › Loki, then for example:

To see LogQL
Every line {service_name="apinx"}
Errors only {service_name="apinx"} | http_response_status_code >= 400
One API {service_name="apinx"} | apinx_api="orders"

Open a line to see all its fields. To jump from a line to its trace, add a derived field to the Loki data source once (Connections › Data sources › Loki › Derived fields): name trace_id, type Label, label trace_id, internal link to your Tempo data source with the query ${__value.raw}. Each line then shows a button that opens its trace.

A ready dashboard

Download apinx-cloud-dashboard.json, then in Grafana: Dashboards › New › Import › Upload dashboard JSON file, pick your Prometheus, Tempo and Loki data sources, and Import.

It shows requests per second, error rate, p95 latency, traffic by status class, error rate and latency by route, a table of routes, traffic by application, the slowest and failed traces, and the request log lines. The Product box at the top takes a pattern on the API name (.* for all, orders.* for one product); Environment, API, Route and Application narrow every panel. To keep one dashboard per product, import it again and set Product to that product's pattern.

What is sent, and what never is

  • Only your organization's requests, named by your APIs, routes, backends and applications, with service.name=apinx and apinx.organization=<your organization>.
  • Never: anything about Apinx's servers, other organizations, query strings, request or response bodies, headers or tokens. The caller's IP and user agent only if you tick the box.
  • Sending costs your requests nothing: it happens in the background, and when your collector is slow or away, what does not fit is dropped and counted on the card. No request waits.