> ## Documentation Index
> Fetch the complete documentation index at: https://onecli.sh/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Coralogix Integration: Logs, Metrics, and Alerts for Agents

> Agents can query Coralogix logs, traces, and metrics, and read alerts, incidents, and dashboards. Connect with an API key.

## Overview

OneCLI connects AI agents to [Coralogix](https://coralogix.com) with an API key. Agents can run DataPrime and PromQL queries over your logs, traces, and metrics, and read alerts, incidents, cases, and dashboards. The gateway injects the key into requests to the Coralogix API, so your agent never sees it.

This suits SRE and debugging agents: pulling the errors behind a spike, correlating an alert with the logs around it, or checking a service's SLO before a deploy.

Connecting takes about two minutes.

<a id="self-hosted" style={{ scrollMarginTop: "8rem" }} />

## Connect Coralogix

<Steps>
  <Step title="Find your Coralogix region">
    Every Coralogix account lives in one region, and a key only works there. Read yours from the address you sign in at:

    | You sign in at | Region |
    | - | - |
    | `<team>.app.coralogix.us` | `us1` |
    | `<team>.app.cx498.coralogix.com` | `us2` |
    | `<team>.app.us3.coralogix.com` | `us3` |
    | `<team>.coralogix.com` | `eu1` |
    | `<team>.app.eu2.coralogix.com` | `eu2` |
    | `<team>.app.coralogix.in` | `ap1` |
    | `<team>.app.coralogixsg.com` | `ap2` |
    | `<team>.app.ap3.coralogix.com` | `ap3` |
  </Step>

  <Step title="Create an API key in Coralogix">
    In Coralogix, open **Settings** > **API Keys** and create a **Personal** or **Team** key. Give it a name such as `onecli-key` and pick its **Role Presets**.

    <Frame caption="Creating a personal key in Coralogix. The role presets decide what the key, and so the agent, can do.">
      <img src="https://mintcdn.com/chartdbinc/t5B79G5cpuCqroIq/images/integrations/coralogix/coralogix-create-personal-key.png?fit=max&auto=format&n=t5B79G5cpuCqroIq&q=85&s=fa60013b1bdfa736690a6b3d1ab6492b" alt="Coralogix Create a new personal key dialog, with Personal Key selected as the key type, the key name onecli-key, a Role Presets field holding several presets, an Advanced section, and Cancel and Create buttons." width="1996" height="1014" data-path="images/integrations/coralogix/coralogix-create-personal-key.png" />
    </Frame>

    For an agent that investigates, choose the **DataQuerying** preset. It can query logs, traces, and metrics, and Coralogix keeps the preset up to date as it adds permissions. Add **Alerts** or **Incidents** permissions only if the agent should read or manage them too.

    Copy the key right away.

    <Tip>
      Prefer a **Team** key for a shared agent. A Personal key stops working when the person who created it leaves the team.
    </Tip>
  </Step>

  <Step title="Paste it in OneCLI">
    In the OneCLI dashboard, open **Connections** > **Coralogix**, paste the key into **API key**, and pick your **Region**. Each option shows its sign-in address, so match the one in your browser. **US2** is selected by default.

    <Frame caption="The Coralogix connect window in OneCLI.">
      <img src="https://mintcdn.com/chartdbinc/sqKVoyjYeGRApbID/images/integrations/coralogix/onecli-connect-coralogix.png?fit=max&auto=format&n=sqKVoyjYeGRApbID&q=85&s=674e4ad4b52dfd0dfe5ca4c27d40b2a1" alt="OneCLI connect window for Coralogix, showing the setup guide link, the API key field with a link to Coralogix's instructions, the Region dropdown set to US2 with its sign-in address, a Find your region link, and the Connect Coralogix button." width="944" height="1380" data-path="images/integrations/coralogix/onecli-connect-coralogix.png" />
    </Frame>

    Select **Connect Coralogix**. OneCLI checks the key against the API in your region before saving it, and names the connection after your Coralogix team.
  </Step>
</Steps>

<Note>
  The gateway always sends a connection's requests to its own region. An agent can call the current host (`api.us2.coralogix.com`) or an older one your scripts already use (`api.cx498.coralogix.com`, `ng-api-http.cx498.coralogix.com`), and it works either way. Log ingestion (`ingress.*`) uses a separate Send-Your-Data key and is not part of this connection.
</Note>

## What agents can do

| Area | What agents can do |
| - | - |
| **Logs and traces** | Run DataPrime or Lucene queries over logs and spans |
| **Metrics** | Run PromQL queries and read metric labels and series |
| **Alerts** | List alert definitions and their triggered events, and create, change, or delete definitions |
| **Incidents** | List, filter, and read incidents, and acknowledge, resolve, close, or assign them |
| **Cases** | List, filter, and read cases with their timelines, and acknowledge, assign, resolve, close, or comment on them |
| **Dashboards** | List and read dashboards, and create, change, or delete them |
| **SLOs** | List SLOs and read their status |
| **Saved views** | List and read saved Explore views |

What a key can actually do is capped by its Coralogix permissions. A DataQuerying key can query but cannot touch alerts or incidents, whatever OneCLI allows.

## Quick example

No `Authorization` header is needed, the gateway adds it. Replace `us2` with your region:

```bash theme={null}
# Last 20 error logs
curl -s -X POST "https://api.us2.coralogix.com/api/v1/dataprime/query" \
  -H "Content-Type: application/json" \
  -d '{"query": "source logs | filter $m.severity == ERROR | limit 20"}'

# Request rate over the last 5 minutes
curl -s "https://api.us2.coralogix.com/metrics/api/v1/query" \
  --data-urlencode 'query=sum(rate(http_requests_total[5m]))'
```

For every endpoint, see the [Coralogix API reference](https://coralogix.com/docs/api-reference/introduction-v5/).

## Controlling access

[Grant](/docs/guides/agent-access) the connection to each agent that needs it, and choose per tool what runs freely, what needs approval, and what's blocked.

A good default is to let agents query logs and metrics freely and put anything that changes state behind approval. Deleting an alert definition silences monitoring for good, and resolving an incident or case hides it from the people working it.

Organization [rules](/docs/guides/rules) add guardrails on top. A blocked request never reaches Coralogix.

To disconnect, remove the connection in **Connections** > **Coralogix**, then delete the key in Coralogix under **Settings** > **API Keys**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.