Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/api/src/observability/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ function read(name: string): string {
/** Which of Grafana's environments this server's lines and metrics are labelled with. */
export const envLabel: EnvLabel = read('NODE_ENV') === 'production' ? 'production' : 'development';

/** Grafana Cloud Loki, where the api ships its log when set; an empty address means stdout alone. */
/** The Loki the api ships its log to when set; an empty address means stdout alone. */
export const lokiConfig: LokiConfig = {
url: read('LOKI_URL'),
userId: read('LOKI_USER_ID'),
token: read('GRAFANA_CLOUD_TOKEN'),
};

/** Grafana Cloud's OTLP gateway, where the api pushes its metrics when set; nothing is pushed otherwise. */
/** Where the api pushes its metrics over OTLP when set; nothing is pushed otherwise. */
export const metricsConfig: Pick<MetricsConfig, 'url' | 'userId' | 'token'> = {
url: read('METRICS_OTLP_URL'),
userId: read('METRICS_USER_ID'),
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/observability/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type {Logger};
export {serializeError} from '@proxy/observability';

/**
* The api's logger: stdout always, and Grafana Cloud Loki when LOKI_URL is set (config.ts). Every
* The api's logger: stdout always, and a Loki when LOKI_URL is set (config.ts). Every
* line carries the request or job it was written in (request-context.ts).
*/
export const log: Logger = createServerLogger({
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/observability/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {type AgentMetrics, createAgentMetrics, createDbMetricsRecorder, createMe
import {envLabel, metricsConfig} from './config';

/**
* The api's metrics, pushed to Grafana Cloud when METRICS_OTLP_URL is set (config.ts) and
* The api's metrics, pushed over OTLP when METRICS_OTLP_URL is set (config.ts) and
* summed up for nothing otherwise. Each instance pushes as itself: Render names it, and a machine
* elsewhere is its host and process.
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/docs/content/self-hosting/environment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ variables turn on quick actions on the home page.
## Observability

The api writes its log to stdout, one JSON object per line, which `docker compose logs api` shows.
These ship it to [Grafana Cloud](https://grafana.com/products/cloud/) as well, which hosted
Personal Agent Proxy does; a self-hosted server needs none of them.
These ship it to a [Loki](https://grafana.com/oss/loki/) as well, and its metrics to a Prometheus
or any other store taking OTLP, as hosted Personal Agent Proxy does; a self-hosted server needs
none of them.

<EnvTable group="Observability" />
6 changes: 3 additions & 3 deletions packages/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ goes. A self-hosted server needs none of it: without the variables below, the ap
to stdout alone, one JSON object per line, and sums its metrics up for nothing.

- `src/server.ts`: the server's logger. Stdout always, as text in development and as JSON lines in
production; Grafana Cloud Loki in batches when set, labelled by service, env and level.
production; a Loki in batches when set, labelled by service, env and level.
- `src/client.ts`: the web app's logger, posted to the api in batches, which writes it on as the
web app's or the desktop app's (`packages/api/src/observability/client-logs.ts`).
- `src/metrics.ts`: counters, histograms and gauges, pushed to Grafana Cloud's OTLP gateway every
half minute. On it `db-metrics.ts` (every query), `tool-metrics.ts` (every request of an agent),
- `src/metrics.ts`: counters, histograms and gauges, pushed over OTLP every half minute, to a
Prometheus or Grafana Cloud's gateway. On it `db-metrics.ts` (every query), `tool-metrics.ts` (every request of an agent),
`agent-metrics.ts` (the built-in agent's jobs and every request of a model), and the probes
`db-pool-probe.ts` (`SELECT 1` each second) and `job-queue-probe.ts` (the AgentJob queue).
- `src/slack.ts`: the Slack notifier the api posts sign-ups with, and the internal repo's admin
Expand Down
Loading