Skip to content

Using a Coding Agent

A coding agent, such as Claude Code or Codex, that builds an app with Prometheus Proxy can read the project's instructions as it works: a skill to install, the docs as Markdown, and a block of rules to keep in the app's repository. Then check what it wrote as you would check your own.

Install the Skill

The skill helps a coding agent:

  • choose between a standalone agent and one embedded in the app;
  • embed the agent in a JVM app, with the Ktor plugin, or with the Spring Boot starter;
  • configure the proxy and standalone agents, with tokens and TLS;
  • write Prometheus's scrape config for the proxy's paths;
  • find why a scrape through the proxy fails.

Its examples are the docs', which the project's build compiles and tests.

In Claude Code 2.1.275 or later:

/plugin install prometheus-proxy --marketplace pambrose/prometheus-proxy

In earlier versions, add the marketplace, then install the plugin:

/plugin marketplace add pambrose/prometheus-proxy
/plugin install prometheus-proxy@prometheus-proxy

Or from a shell:

claude plugin marketplace add pambrose/prometheus-proxy
claude plugin install prometheus-proxy@prometheus-proxy

Other Coding Agents

The skill is in the Agent Skills format, so another coding agent that reads the format can use its directory, plugins/prometheus-proxy/skills/prometheus-proxy, as it is. Copy it to where the coding agent reads skills, such as .agents/skills/ in the app's repository for Codex, or .claude/skills/ for Claude Code. From the app's repository:

tmp=$(mktemp -d)
git clone --depth 1 https://github.com/pambrose/prometheus-proxy.git "$tmp"
mkdir -p .agents/skills
cp -R "$tmp/plugins/prometheus-proxy/skills/prometheus-proxy" .agents/skills/

The Docs as Markdown

Every page of these docs is also served as Markdown, with its code examples in place, for a coding agent to read: add index.md to a page's URL, as in https://prometheus-proxy.com/embedded-agent/index.md.

  • llms.txt tells a coding agent what the project is, which way to run the agent, and the rules for its code and config, then links to each page's Markdown.
  • llms-full.txt holds every page but the demos' in one file.

Point a coding agent without the skill at llms.txt before it starts. The rules below do that for every session.

Rules for Your App's AGENTS.md

A coding agent reads the instructions in a repository's AGENTS.md at the start of every session. Paste this block into your app's, so the coding agent reads the docs before it writes code or config for Prometheus Proxy, and avoids the mistakes that make a setting do nothing or a scrape fail:

## Prometheus Proxy

Prometheus scrapes this app's metrics through Prometheus Proxy: Prometheus scrapes
a proxy outside the firewall, which passes each scrape to an agent inside it, over
a gRPC connection the agent opened to the proxy.

- **Read the docs first.** Before writing code or config for Prometheus Proxy, use
  the prometheus-proxy skill if it's installed, or else read
  https://prometheus-proxy.com/llms.txt, then the pages it links to for the task.
  Write for the release this app's build names. The docs describe the latest
  release, and when the build names an older one, the upgrading pages say what each
  release changed: for a standalone proxy and agent,
  https://prometheus-proxy.com/upgrading/index.md, and for an embedded agent,
  https://prometheus-proxy.com/embedded-upgrading/index.md.
- **Use only settings that exist.** A config key the agent or the proxy doesn't
  know has no effect. Take keys from the docs' configuration pages, and in an
  embedded agent prefer the builder's typed methods to `setting(key, value)`. After
  changing a config, check the startup log for this WARN, which names the key, and
  the nearest setting when one is near: `isn't a setting, so it has no effect`.
  Spring Boot ignores a `prometheus-proxy.agent` property it doesn't know, so check
  those against https://prometheus-proxy.com/spring-boot-starter/#properties.
- **Prometheus scrapes the proxy, not the app.** Its target is the proxy's scrape
  port, 8080 by default, and its `metrics_path` is the path the agent registered,
  with one leading slash.
- **Secrets come from the environment,** never a committed file. An embedded
  agent's `fromEnvironment()` reads `PROMETHEUS_PROXY`, `PROMETHEUS_AGENT_TOKEN`,
  and `PROMETHEUS_PROXY_CERT`, and a standalone agent reads its token from
  `AGENT_TOKEN`.
- **Start and stop an embedded agent with the app.** `startIfConfigured()` returns
  null when no proxy is set, so the app runs without it. Close the
  `EmbeddedAgentInfo` it returns when the app stops. The Ktor plugin and the Spring
  Boot starter do both.

Check What It Wrote

Three checks show that the code and config work:

  1. Every setting exists. At startup, the agent and the proxy each log a WARN for every key in their config section that isn't a setting, naming the nearest setting when one is near. A coding agent that names a setting from memory can name one that never existed:

    The agent's log
    agent.scrapeTimeoutSec isn't a setting, so it has no effect; did you mean agent.scrapeTimeoutSecs?
    

    Spring Boot ignores a prometheus-proxy.agent property it doesn't know, so check a Spring Boot app's against the starter's Properties.

  2. The agent registered its paths. Its log says it connected to the proxy, then registered each path, with the target it scrapes, or in-process for a registry it reads:

    The agent's log
    Connected to proxy at localhost:50051 using plaintext
    Registered in-process as /my_app_metrics with labels {} (static)
    
  3. The path scrapes through the proxy, as Prometheus will scrape it:

    curl -i http://localhost:8080/my_app_metrics
    

    HTTP/1.1 200 OK, followed by the metrics, means every hop works.

When one of them fails, Troubleshooting goes through the causes, and Debugging an Embedded Agent shows where an embedded agent logs and what else to look at.