Skip to main content

Query profiles from the CLI, MCP, and Olly

Read the same CPU, wall-clock, and memory profiles the Profiles catalog shows without opening Coralogix: from a terminal or a script with the CX CLI, from a coding agent through the Coralogix MCP server, or by asking Olly in plain language. All three rank profiled services by usage, split that usage by pod or label over time, and decode a flame graph into a call tree plus the functions with the highest self value.

What you need​

  • Continuous Profiling set up on the services you want to query. Only profiled services return data.
  • The PROFILES.CPU-PROFILES:READ permission, on the API key or the role each client authenticates with. It covers every profile type, CPU, wall-clock, and memory alike. See Continuous Profiling permissions.
  • For the terminal route, CX CLI v0.1.29 or later, with a configured profile. See the CX CLI quickstart.
  • For a coding agent, an MCP client connected to the Coralogix MCP server with the profiling toolset loaded. See Choosing toolsets.
  • For the chat route, Olly enabled for your team.

From the CX CLI​

cx profiling reads profiling data over five read-only subcommands.

SubcommandWhat it returnsMain options
cx profiling services --category cpu|memoryProfiled services, highest usage first--environment, --limit (default 20, max 100), --offset, --include-time-series
cx profiling metadata <service>A service's language and which profile types have data
cx profiling filters <service> --profile-type <type>The label keys a service's profiles can be filtered by, with their values--filter, --max-values-per-key (default 50)
cx profiling metrics <service> --profile-type <type>One profile type's usage over time, split by service, pod, or any label--sum-by (default service), --limit (default 10), --max-buckets (default 60), --filter
cx profiling flame-graph <service> --profile-type <type>A decoded flame graph plus the functions with the highest self value--top-functions (default 20), --min-node-ratio (default 0.01), --max-depth, --show-kernel, --filter

Options shared by every subcommand:

  • Time range: --start and --end accept now, relative expressions such as now-6h, or ISO 8601 timestamps. They default to now-1h and now.
  • Profile type: cpu, wall, memory-allocation-bytes, memory-allocation-objects, memory-heap-bytes, or memory-heap-objects, case-insensitive.
  • Filters: --filter is repeatable and the filters combine with AND. Each one takes the form key=v1,v2 (any of the values), key!=v1,v2 (none of them), key:exists, or key:not-exists. Discover the keys and values with cx profiling filters.
  • Output: add -o json or -o toon for machine-readable output, and repeat -p <profile> to fan the same query out across several CLI profiles.

Example: rank services by CPU​

List the 10 services that spent the most CPU over the last 6 hours. The ranking is computed server-side on CPU plus wall-clock seconds for cpu, and on allocated plus heap bytes for memory. Each row carries the service name, its language, its usage totals for the category, and when it was last active.

cx profiling services --category cpu --limit 10 --start now-6h

Pass the service name back verbatim to the other subcommands.

Example: find a flame graph's hottest functions​

Read the functions with the highest self value in one service's CPU profile. Each entry names the function, its file, and its self value in both absolute and percentage terms. The list is summed over every call path in the full graph, so tree trimming does not change it.

cx profiling flame-graph checkout --profile-type cpu --top-functions 10

To attribute a spike to one pod first, confirm the service has CPU data, split the usage by pod, then scope the graph to the pod and the period where usage was high:

cx profiling metadata checkout
cx profiling metrics checkout --profile-type cpu --sum-by pod --start now-6h
cx profiling flame-graph checkout --profile-type cpu --filter k8s.pod.name=checkout-7d9f4 --start now-6h

Take the pod name from the metrics output, and the filter key from cx profiling filters. Narrow --start and --end to the period the chart shows as busy: a graph over a long, mostly idle window hides the spike.

Keep in mind:

  • Check the profile types first. cx profiling metadata lists which types have data, and metrics and flame-graph return nothing for a type with no data in the window.
  • A flame graph is the expensive call. One can take around 40 seconds on a large service, so avoid a short --http-timeout, and narrow the service, profile type, time range, and filters before asking for a graph.
  • The services ranking is fixed. --environment is the only filter it honors and there is no alternative sort order. When a page comes back full, the command prints the --offset to pass for the next page.
  • A high self value means the function itself is hot. A high total with a low self value means the cost sits in what it calls.

For every flag, see the cx profiling command reference.

From the MCP server​

The Coralogix MCP server exposes profiling to your coding agent through the read-only query_profiling tool and a profiling skill, both in the profiling toolset. Ask the agent in plain language, for example "Which services used the most CPU in the last 6 hours?" or "What is checkout spending its CPU on?" The agent picks one of five actions and reads the window you asked about.

ActionWhat it returns
list_servicesOne page of profiled services for one category, highest usage first
service_metadataA service's language and which profile types have data in the window
filtersThe labels a service's data can be filtered or split by, with their values
metricsOne profile type's usage over time, optionally split by pod or a label
flame_graphA decoded call tree plus the top functions by self value

The agent can rank services by CPU or memory, narrow them to an environment, find when usage changed and which pod or version drove it, and read the code paths behind it. To compare two windows, such as before and after a deploy, it reads a flame graph for each window and compares the percentages rather than the raw values.

Keep in mind:

  • Service names come from the profiling data. A profiled service name is often, but not always, the same as $l.serviceName in logs and spans, because some are Kubernetes workload names. When a name taken from another source does not match, ask the agent to search for it by substring. The search covers the top 1000 services and says when more exist.
  • The call tree is trimmed before you see it. Coralogix drops frames below 0.1% of the total, and the tool then drops subtrees below 1% of the graph and frames deeper than 20 levels. Ask for a lower threshold or a greater depth to see smaller or deeper frames, and narrow the window or add a filter when the tree is cut short to fit the response.
  • Partial results are flagged. When a query limit is hit, the answer says the graph covers only part of the range.

With OAuth or a personal API key, the server reads profiles with your own permissions. With a team API key, it uses the permissions attached to the key. See MCP server permissions.

From Olly​

Olly answers code-level CPU and memory questions with the same tool and its built-in profiling skill. You don't have to name the skill: Olly loads it for questions that need in-depth investigation, such as why a service uses so much CPU or memory, which code paths are responsible, whether memory is growing or leaking, and what changed between two time windows. Ask it, for example:

  • Which services used the most memory this morning?
  • Why is checkout burning CPU? Show me the hottest functions.
  • Which pod drove the CPU spike on checkout at 10:00?

Olly reads the Service Catalog for how much a service uses and when, and profiles for why. Olly inherits your own permissions, so it reaches the same profiling data your role already allows. When a service has no profiling data, Olly answers from the Service Catalog or from metrics instead and tells you that function-level detail needs profiling enabled for that service.

Keep in mind:

  • Allocation and heap answer different questions. Allocation profiles show how much memory code allocates, including short-lived churn, so a wide allocation frame marks where code allocates rather than a fault. Heap profiles show memory that is still retained, so a wide frame there is a leak or unbounded-growth candidate. A single heap capture shows composition at one moment, so confirm growth over a longer range or against a second window before calling it a leak.
  • Profiles explain code-level cost. For error rates, latency percentiles, or throughput, Olly uses the Service Catalog, spans, or metrics.

For how built-in skills are loaded and called, see Olly skills.

Next steps​

Last updated on