This tutorial demonstrates configuring [OpenTelemetry](https://coralogix.com/docs/opentelemetry/getting-started/index.md) (OTEL) Collector to send your logs and metrics to Coralogix using Docker.

## Prerequisites

- Docker [installed](https://docs.docker.com/engine/install/)

## Configuration

**STEP 1**. Create a configuration file. Copy this template file and save it as `config.yaml`.

```yaml
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 ]
```

Provide the following variables.

| Variable         | Description                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Private Key      | Your Coralogix [**Send-Your-Data API key**](https://coralogix.com/docs/user-guides/account-management/api-keys/send-your-data-api-key/index.md)                                                                                                                                                                                                                                                          |
| Application Name | The name of your [**application**](https://coralogix.com/docs/user-guides/account-management/account-settings/application-and-subsystem-names/index.md), as it will appear in your Coralogix dashboard. For example, a company named SuperData might insert the SuperData string parameter. If SuperData wants to debug its test environment, it might use SuperData–Test.                               |
| Subsystem Name   | The name of your [**subsystem**](https://coralogix.com/docs/user-guides/account-management/account-settings/application-and-subsystem-names/index.md), as it will appear in your Coralogix dashboard. Applications often have multiple subsystems (ie. Backend Servers, Middleware, Frontend Servers, etc.). In order to help you examine the data you need, inserting the subsystem parameter is vital. |
| Domain           | Your Coralogix **[domain](https://coralogix.com/docs/user-guides/account-management/account-settings/coralogix-domain/index.md)**                                                                                                                                                                                                                                                                        |

**STEP 2**. Save this log file as `example.log`.

```text
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
```

**STEP 3**. Pull a docker image and run the collector in a container. To load your custom configuration `config.yaml` and the log file `example.log` from your current working directory, mount the files as a volume into the container. Find out more [here](https://opentelemetry.io/docs/collector/getting-started/#docker).

```bash
docker pull otel/opentelemetry-collector-contrib
docker run -d -v "$(pwd)"/config.yaml:/etc/otelcol-contrib/config.yaml -v "$(pwd)"/example.log:/example.log otel/opentelemetry-collector-contrib
```

## **Validation**

Validate your configuration.

### Logs

In your Coralogix navigation pane, click **LiveTrail** **> Start** to view your logs.

### Metrics

**STEP 1**. Navigate to [hosted Grafana view](https://coralogix.com/docs/user-guides/visualizations/hosted-grafana-view/index.md).

**STEP 2**. In the left-hand panel, click **Explore > Metrics browser.** Select the metrics that you would like to see.

## Additional Resources

|               |                                                                                    |
| ------------- | ---------------------------------------------------------------------------------- |
| Documentation | [OpenTelemetry](https://coralogix.com/docs/opentelemetry/getting-started/index.md) |

## **Support**

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email at [support@coralogix.com](mailto:support@coralogix.com).
