# Running OpenTelemetry as a CLI application

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fopentelemetry%2Fintegrations%2Frunning-opentelemetry-as-a-cli-application.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fopentelemetry%2Fintegrations%2Frunning-opentelemetry-as-a-cli-application.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

Configure the [OpenTelemetry](https://coralogix.com/docs/opentelemetry/getting-started.md) Collector to send logs and host metrics to Coralogix when you run it directly (as a CLI binary or as a service) rather than in a cluster.

## What you need [​](#what-you-need- "Direct link to what-you-need-")

* The Collector installed. It must be [opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib), not the core distribution, the Coralogix exporter ships only in contrib. Download a build for your OS from the [releases page](https://github.com/open-telemetry/opentelemetry-collector-releases/releases/).
* A Coralogix [Send-Your-Data API key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key.md).
* Your [Coralogix domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain.md).

## Configure the Collector [​](#configure-the-collector- "Direct link to configure-the-collector-")

1

<!-- -->

.

Create the configuration file

Save this as `config.yaml`. It tails a log file and scrapes CPU and memory, then exports both to Coralogix.

```
receivers:

  filelog:

    start_at: beginning

    include:

      - /example.log

    include_file_path: true

    multiline: {line_start_pattern: "\\n"}

  hostmetrics:

    collection_interval: 30s

    scrapers:

      cpu:

      memory:

exporters:

  coralogix:

    domain: "Domain"

    private_key: "Private key"

    application_name: "Application Name"

    subsystem_name: "Subsystem Name"

    timeout: 30s



service:

  pipelines:

    logs:

      receivers: [ filelog ]

      exporters: [ coralogix ]

    metrics:

      receivers: [ hostmetrics ]

      exporters: [ coralogix ]
```

| Value              | What to enter                                                                                                                                                                                                                                                                             |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `private_key`      | Your Coralogix [Send-Your-Data API key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key.md)                                                                                                                                                     |
| `domain`           | Your Coralogix [domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain.md)                                                                                                                                                                   |
| `application_name` | The [application](https://coralogix.com/docs/user-guides/account-management/account-settings/application-and-subsystem-names.md) name shown in your dashboard. A company called SuperData might use `SuperData`, or `SuperData-Test` for a test environment                               |
| `subsystem_name`   | The [subsystem](https://coralogix.com/docs/user-guides/account-management/account-settings/application-and-subsystem-names.md) name shown in your dashboard. Most applications have several (backend servers, middleware, frontend servers) and this is what lets you separate them later |

2

<!-- -->

.

Create a log file to read

Save this as `example.log`, so there is something for the `filelog` receiver to pick up.

```
2023-06-19 05:20:50 ERROR This is a test error message

2023-06-20 12:50:00 DEBUG This is a test debug message

2023-06-21 12:34:56 INFO This is a test info message
```

3

<!-- -->

.

Run the Collector

Use the form that matches your installation.

```
# Installed as an application

./otelcol-contrib --config config.yaml



# Installed as a service

otelcol-contrib --config config.yaml
```

## Validate the logs [​](#validate-the-logs- "Direct link to validate-the-logs-")

In Coralogix, select **LiveTail**, then **Start**. The three test lines arrive as structured records under the application and subsystem names you configured.

[![Coralogix LiveTail showing three OpenTelemetry log records with severity, application, subsystem, and body fields](/docs/assets/images/Untitled-19-1024x675-9ef0fbc7b0cd0ed5ab7c6057cf8ed13d.webp)](https://coralogix.com/docs/assets/images/Untitled-19-1024x675-9ef0fbc7b0cd0ed5ab7c6057cf8ed13d.webp)

Shows the test file's error, debug, and info lines as they arrive.

## Validate the metrics [​](#validate-the-metrics- "Direct link to validate-the-metrics-")

1

<!-- -->

.

Open Grafana

Go to the [hosted Grafana view](https://coralogix.com/docs/user-guides/visualizations/hosted-grafana-view.md).

2

<!-- -->

.

Browse the metrics

In the left-hand panel, select **Explore**, then **Metrics browser**, and select a metric. The host metrics receiver produces `system_cpu_time_total` and `system_memory_usage_By`.

[![Grafana metrics browser with the host metrics produced by the Collector listed for selection](/docs/assets/images/Untitled-3-1-1fb85b449db845cc4426681cce0d7a7d.webp)](https://coralogix.com/docs/assets/images/Untitled-3-1-1fb85b449db845cc4426681cce0d7a7d.webp)

Shows the CPU and memory series the `hostmetrics` scrapers emit.

## Related resources[​](#related-resources "Direct link to Related resources")

[OpenTelemetry Collector](https://coralogix.com/docs/opentelemetry/getting-started.md)[Hosted Grafana view](https://coralogix.com/docs/user-guides/visualizations/hosted-grafana-view.md)[Send-Your-Data API key](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key.md)
