# Kubernetes monitoring

Pod logs, node and pod metrics and your services' traces from a Kubernetes cluster, with two Helm charts you may already know.

Two standard agents do the work: Fluent Bit reads every container's logs on each node, and the OpenTelemetry Collector collects metrics from the kubelet and receives your services' traces. Both send to Flowhawk with one ingest key. Nothing Flowhawk-specific runs in your cluster.

## What you get

- Every container's logs in [Logs](https://flowhawk.dev/docs/signals#logs), named after the container, with the pod, namespace and labels as attributes.
- CPU, memory, network and restarts per node, pod and container in [Metrics](https://flowhawk.dev/docs/signals#metrics), and a ready-made Kubernetes pods dashboard under **New dashboard**.
- Your services' traces with the pod and node they ran on, matched to your [business flows](https://flowhawk.dev/docs/flows).
- A container named after a service shows on that service's page, so a failing flow leads to the pods behind it.

## Set it up

First create an ingest key: in the app, open **Settings > API keys** and pick **Services**. In the examples below, `KEY` stands for that key. Keep it out of your repository, like any other secret.

Put it in a secret both charts can read:

```
kubectl create namespace observability
kubectl -n observability create secret generic flowhawk --from-literal=key=KEY
```

### 1. Logs with Fluent Bit

The Fluent Bit chart already tails container logs and adds Kubernetes metadata, and merges JSON log lines into fields. Replace its output with Flowhawk:

```
# fluent-bit.yaml
env:
  - name: FLOWHAWK_KEY
    valueFrom: { secretKeyRef: { name: flowhawk, key: key } }
config:
  outputs: |
    [OUTPUT]
        Name   http
        Match  kube.*
        Host   api.flowhawk.dev
        Port   443
        URI    /v1/logs/fluentbit
        Format json
        tls    On
        Header Authorization Bearer ${FLOWHAWK_KEY}
```

```
helm repo add fluent https://fluent.github.io/helm-charts
helm upgrade --install fluent-bit fluent/fluent-bit \
  -n observability -f fluent-bit.yaml
```

### 2. Metrics and traces with the OpenTelemetry Collector

Run the collector on every node. Its presets add the kubelet's metrics and tag everything with the pod, namespace and node:

```
# otel-collector.yaml
mode: daemonset
image:
  repository: otel/opentelemetry-collector-k8s
presets:
  kubernetesAttributes: { enabled: true }
  kubeletMetrics: { enabled: true }
extraEnvs:
  - name: FLOWHAWK_KEY
    valueFrom: { secretKeyRef: { name: flowhawk, key: key } }
config:
  exporters:
    otlphttp/flowhawk:
      endpoint: https://ingest.flowhawk.dev
      headers:
        Authorization: Bearer ${env:FLOWHAWK_KEY}
  service:
    pipelines:
      traces:  { exporters: [otlphttp/flowhawk] }
      metrics: { exporters: [otlphttp/flowhawk] }
```

```
helm repo add open-telemetry \
  https://open-telemetry.github.io/opentelemetry-helm-charts
helm upgrade --install otel-collector open-telemetry/opentelemetry-collector \
  -n observability -f otel-collector.yaml
```

For cluster-level metrics (deployments, replicas, pod phases), install the same chart a second time with `mode: deployment`, `replicaCount: 1` and the `clusterMetrics` preset.

### 3. Point your services at the collector on their node

```
env:
  - name: HOST_IP
    valueFrom: { fieldRef: { fieldPath: status.hostIP } }
  - name: OTEL_EXPORTER_OTLP_ENDPOINT
    value: http://$(HOST_IP):4318
  - name: OTEL_SERVICE_NAME
    value: orders
```

Then add OpenTelemetry or a Flowhawk SDK to each service ([language guides](https://flowhawk.dev/docs/languages)). Name each container after its service, so logs, metrics and traces meet on one service page.

## Check it arrived

Open **Setup** in the app. It lists each service that sent data in the last 15 minutes. If yours isn't there, [Help and troubleshooting](https://flowhawk.dev/docs/help) says why telemetry can be refused (a wrong key, an empty balance) and how to see it.

## Common questions

### Can services send straight to Flowhawk instead?

Yes. Set `OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.flowhawk.dev` and the key header in each service, as the framework guides show. The collector on the node is still what collects the kubelet's metrics.

### Can I drop noisy namespaces?

Yes. Narrow Fluent Bit's `Match`, or add a `grep` filter on `$kubernetes['namespace_name']`. In Flowhawk, a flow's collection settings also decide which levels of its logs are kept.

## Related

[**OpenTelemetry Collector**Send everything your OpenTelemetry Collector receives to Flowhawk, and collect host and container metrics on the way.](https://flowhawk.dev/integrations/opentelemetry-collector) [**Docker container logs**Collect the logs of every container on a Docker host and send them to Flowhawk, named by container.](https://flowhawk.dev/integrations/docker-logs) [**Prometheus Remote Write**Send metrics you already collect with Prometheus or Grafana Alloy to Flowhawk with Remote Write 2.0.](https://flowhawk.dev/integrations/prometheus-remote-write)

[Try it free for 14 days](https://app.flowhawk.dev/signup?trial=1) [Read the getting started guide](https://flowhawk.dev/docs/getting-started)

---

URL: https://flowhawk.dev/integrations/kubernetes-monitoring
