# OpenTelemetry

Contents

* [OpenTelemetry](https://docs.hostedgraphite.com/agents-guide/opentelemetry)
  * [Linux Installation](#linux-installation)
  * [Configuration](#configuration)
  * [OpenTelemetry Dashboard](#open-telemetry-dashboard)

## [OpenTelemetry](#opentelemetry)

[OpenTelemetry](https://opentelemetry.io/docs/) makes a great collector agent because it provides a scalable way to collect and process metrics, traces, and logs in a single pipeline. To use OpenTelemetry as a collector agent, [install the Contrib version](https://opentelemetry.io/docs/collector/installation/) (otelcol-contrib) instead of the Core version, as it includes extended features needed to forward Graphite metrics.

### [Linux Installation](#linux-installation)

Download the OpenTelemetry Contrib Collector package and unpack it. See their [installation docs](https://opentelemetry.io/docs/collector/installation/) for the latest versions and details on installing to different systems. Packages and files are generally installed at `/etc/otelcol-contrib/`

**Ubuntu/Debian (AMD):**

```
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.118.0/otelcol-contrib_0.118.0_linux_amd64.deb
sudo dpkg -i otelcol-contrib_0.118.0_linux_amd64.deb
```

**RedHat/CentOS (AMD):**

```
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.119.0/otelcol-contrib_0.119.0_linux_amd64.rpm && \
sudo rpm -ivh otelcol-contrib_0.119.0_linux_amd64.rpm
```

### [Configuration](#configuration)

Locate the configuration file at: `/etc/otelcol-contrib/config.yaml` and open it in your preferred text editor. To use OpenTelemetry Contrib as a collector agent, you must enable the [hostmetrics receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/hostmetricsreceiver/README.md) and [carbon exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/carbonexporter/README.md). Simply replace the config.yaml file, or include the following on your current config file (make sure to add your HG-API-KEY and HOSTNAME):

```yaml
receivers:
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu: {}
      memory: {}
      load: {}
      filesystem: {}
      disk: {}
      paging: {}
      network: {}
      processes: {}
      process: {}
      system: {}

processors:
  batch: {}
  metricstransform:
    transforms:
      - include: ".*"
        match_type: regexp
        action: update
        new_name: "<HG-API-KEY>.opentel.$$0"
        operations:
          - action: add_label
            new_label: host
            new_value: <HOSTNAME>

exporters:
  carbon:
    endpoint: "carbon.hostedgraphite.com:2003"
    timeout: 10s

service:
  pipelines:
    metrics:
      receivers:
        - hostmetrics
      processors:
        - batch
        - metricstransform
      exporters:
        - carbon
```

* Save your changes and start the otelcol-contrib service: `sudo systemctl restart otelcol-contrib`. Within two minutes, tagged system metrics will be forwarded to your Hosted Graphite account (with the ‘opentel’ prefix).
* You can also serve the file manually, to help troubleshoot configuration errors: `otelcol-contrib --config /etc/otelcol-contrib/config.yaml`

### [OpenTelemetry Dashboard](#open-telemetry-dashboard)

Our suggested configuration for OpenTelemetry will return [Tagged Metrics](https://docs.hostedgraphite.com/sending-metrics/graphite-tag-support) to the Hosted Graphite backend. We have a handy dashboard in our [Dashboard Library](https://docs.hostedgraphite.com/dashboard-and-graphs/dashboard-library) that you can generate to quickly visualize your system performance metrics - per host:

<figure><img src="https://495119770-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZtHmoGZNsmARIViZEdbz%2Fuploads%2FqIc6wnhw1qU3GdPwsywu%2Fopentelemetry-dashboard.png?alt=media&#x26;token=d20bd983-89ef-483d-946f-d273a0ee9d14" alt=""><figcaption><p>OpenTelemetry Agent Dashboard</p></figcaption></figure>

If you need help or advice configuring OpenTelemetry as an agent, please send a message to: [support@hostedgraphite.com](mailto:support%40hostedgraphite.com) and we would be happy to walk you through the process.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hostedgraphite.com/agents-guide/opentelemetry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
