# OpenTelemetry Collector on a Host Environment

To install OpenTelemetry Collector on a Host Environment, such as BareMetal host or on a VM instance, see OpenTelemetry documentation on how to [Install the Collector](https://opentelemetry.io/docs/collector/installation/#linux).

## Basic OpenTelemetry Deployment on Host Environments

When deploying OpenTelemetry Collector on a Host Environments, refer to [Basic OpenTelemetry Integration on Host Environments](https://docs.kloudfuse.com/platform/3.3.6/agent-otel-host/#ex-basic).

See [OpenTelemetry Runtime Metrics](https://docs.kloudfuse.com/platform/3.3.6/agent-otel-runtime-metrics/) and [Container Resource Attributes Collection for Telemetry Data](https://docs.kloudfuse.com/platform/3.3.6/agent-otel-containers/) for optional deployment configurations.

### Basic OpenTelemetry Integration on Host Environments

```yaml
receivers:
  otlp:
    protocols:
      grpc:
      http:
        cors:
          allowed_origins:
            - "http://*"
            - "https://*"

exporters:
  otlphttp:
    logs_endpoint: https://<REPLACE WITH KFUSE ADDRESS>/ingester/otlp/v1/logs
    metrics_endpoint: https://<REPLACE WITH KFUSE ADDRESS>/ingester/otlp/metrics
    traces_endpoint: https://<REPLACE WITH KFUSE ADDRESS>/ingester/otlp/traces

processors:
  batch:
    timeout: 10s
  resource:
    attributes:
    - key: kf_platform
      value: "host"
      action: upsert
  resourcedetection:
    detectors:
    - env
    - system
    - ec2
    - gcp
    - azure
    override: true
    timeout: 2s

connectors:
  spanmetrics:

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch, resource, resourcedetection]
      exporters: [otlphttp]
    metrics:
      exporters: [otlphttp]
      processors: [batch, resource, resourcedetection]
      receivers: [otlp]
    logs:
      exporters: [otlphttp]
      processors: [batch, resource, resourcedetection]
      receivers: [otlp]
```

## Host and System-Level Metrics

Kloudfuse APM Services integrate with host and System Metrics to show related infrastructure metrics. See [Service Detail Infrastructure](https://docs.kloudfuse.com/platform/3.3.6/apm-service-detail-infra/).

You can export these metrics using either [Datadog agent](https://docs.kloudfuse.com/platform/3.3.6/agent-datadog-host/), or the OpenTelemetry collector.

When using the OpenTelemetry Collector, you must update it with additional configurations. Specifically, enable `hostmetrics` receivers, add additional `kf_metrics_agent` resource attributes. See [Enable Additional Attributes for System-Level Metrics](https://docs.kloudfuse.com/platform/3.3.6/agent-otel-host/#ex-system-level-metrics).

### Enable Additional Attributes for System-Level Metrics

```yaml
receivers:
 ...
  hostmetrics:
    collection_interval: 30s
    scrapers:
      cpu:
        metrics:
          system.cpu.utilization:
            enabled: true
      memory:
        metrics:
          system.memory.utilization:
            enabled: true
      disk:
      filesystem:
        metrics:
          system.filesystem.utilization:
            enabled: true

processors:
  batch:
    timeout: 10s
  resource:
    attributes:
    - key: kf_platform
      value: "host"
      action: upsert
    - key: kf_metrics_agent
      value: "otlp"
      action: upsert
  resourcedetection:
    detectors:
    - env
    - system
    - ec2
    - gcp
    - azure
    override: true
    timeout: 2s

service:
  pipelines:
   ...
    metrics:
      exporters: [otlphttp]
      processors: [batch, resource, resourcedetection]
      receivers: [otlp, hostmetrics]
```

## Host-Level Metrics

The Kloudfuse **APM Services** page integrates with host metrics to show related infrastructure metrics. To see the infrastructure metrics, select a service, scroll down to the secondary horizontal menu, and select the **Infra** option.

You can export these metrics into Kloudfuse using the Datadog agent, or from the OpenTelemetry collector itself. When using the OpenTelemetry Collector, you must update its configuration. Specifically, enable `hostmetrics` receivers, and add additional `kf_metrics_agent` resource attributes.

### Host-Level Metrics Configuration

service:
  pipelines:
   ...
    metrics:
      exporters: [otlphttp]
      processors: [batch, resource, resourcedetection]
      receivers: [otlp, hostmetrics]
```
