# OpenTelemetry Collector

import { Tabs, TabsContent, TabsList, TabsTrigger } from "zudoku/ui/Tabs"

{/* vale off */}
{/* THIS FILE WAS AUTOGENERATED FROM THE PUBLIC EXAMPLE REPOSITORY. DO NOT EDIT THIS FILE DIRECTLY. */}


This example uses [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/), a vendor-agnostic
implementation of how to receive, process and export telemetry data.
OpenTelemetry Collector works with Unikraft / Unikraft Cloud to process telemetry data.

To run this example, follow these steps:

1. Install the [unikraft CLI](/cli).
   You need a [BuildKit](https://github.com/moby/buildkit) builder. The easiest way to get one is via [Docker](https://docs.docker.com/engine/install/).
   Alternatively, you can also directly set up and use BuildKit, see the [quick start](https://github.com/moby/buildkit#quick-start).

2. Clone the [`examples` repository](https://github.com/unikraft-cloud/examples) and `cd` into the `examples/opentelemetry-collector/` directory:

   ```bash
   git clone https://github.com/unikraft-cloud/examples
   cd examples/opentelemetry-collector/
   ```

Make sure to log into Unikraft Cloud and pick a [metro](/platform/metros) close to you.
This guide uses `fra` (Frankfurt, 🇩🇪):

```bash
unikraft login
```

When done, invoke the following command to deploy this app on Unikraft Cloud:

```bash
unikraft build . --output <my-org>/opentelemetry-collector:latest
unikraft run --metro fra \
  -m 1536M \
  --image <my-org>/opentelemetry-collector:latest
```

The output shows the instance details:

```ansi
[1mmetro[22m:        fra
[1mname[22m:         opentelemetry-collector-bvtnh
[1muuid[22m:         40e8b154-b3b6-4312-ae69-2cdb794b15e4
[1mstate[22m:        [38;2;144;161;185mstarting[0m
[1mimage[22m:        <my-org>/opentelemetry-collector
[1mresources[22m:
[3m  memory[23m:     1536MiB
[3m  vcpus[23m:      1
[1mnetworks[22m:
[3m- uuid[23m:       e74ba590-cbec-404b-d076-16aca1b52404
[3m  private-ip[23m: 10.0.3.3
[3m  mac[23m:        12:b0:aa:f7:b9:26
[1mtimestamps[22m:
[3m  created[23m:    just now
```

In this case, the instance name is `opentelemetry-collector-bvtnh`.
They're different for each run.

Note that the instance doesn't export a service.
The default configuration can receive telemetry data from other instances by specifying the private IP or internal DNS as destination.
Use port 4317 for gRPC and port 4318 for HTTP.
The only configured exporter is the debug exporter.
Feel free to change and redeploy!

You can list information about the instance by running:

```bash
unikraft instances list
```

```ansi
[1mMETRO[22m  [1mNAME[22m                           [1mSTATE[22m    [1mIMAGE[22m                   [1mARGS[22m  [1mMEMORY[22m   [1mVCPUS[22m  [1mFQDN[22m  [1mCREATED[22m
fra    opentelemetry-collector-bvtnh  [38;2;0;188;125mrunning[0m  <my-org>/opentelemetry        1536MiB  1            2 minutes ago
```

When done, you can remove the instance:

```bash
unikraft instances delete opentelemetry-collector-bvtnh
```

## Customize your app

To customize the OpenTelemetry Collector app, update `Kraftfile` or, more likely, the `rootfs/etc/otel/config.yaml` files:

You can update the `rootfs/etc/otel/config.yaml` file as detailed in the [documentation](https://opentelemetry.io/docs/collector/configuration/).
Such as adding another export, apart from the debug exporter.

## Learn more

Use the `--help` option for detailed information on using Unikraft Cloud:

```bash
unikraft --help
```

Or visit the [CLI Reference](/cli/unikraft).
{/* vale on */}
