## Kfuse-Knight Agent for Instrumentation-less tracing

The Kfuse-Knight agent collects and aggregates dynamic data on nodes using the [Extended Berkeley Packet Filter (eBPF)](https://docs.kloudfuse.com/platform/3.2.5/glossary/#ebpf). It runs as a daemonset on a Kubernetes cluster, and can automatically trace protocol-specific network traffic to and from the containers to generate [RED](https://docs.kloudfuse.com/platform/3.2.5/glossary/#red) metrics. By default, this agent enables tracing for the http protocol. Contact mailto:support@kloudfuse.com to enable collection for other protocols.

The Kfuse Knight pod exposes [RED](https://docs.kloudfuse.com/platform/3.2.5/glossary/#red) metrics as a Prometheus metrics endpoint; both Prometheus and Datadog can discover and scrape these metrics.

## Install the Kfuse-Knight Agent

1. Create a namespace.
   ```console
   kubectl create namespace kfuse-knight
   ```

Get the container registry key from kloudfuse <token>.json — uploaded to the page.

1. Create a k8s secret to use this registry access token. The helm uses it to upgrade and install.

Use either [Ubuntu OS](https://docs.kloudfuse.com/platform/3.2.5/agent-kfuse-knight/#ubuntu) or [Windows OS](https://docs.kloudfuse.com/platform/3.2.5/agent-kfuse-knight/#windows).

- Ubuntu OS
   - Windows OS

```console
   cat token.json | docker login -u _json_key  --password-stdin https://us-east-1-docker.pkg.dev
   kubectl create secret docker-registry kfuse-image-pull-credentials \
           --namespace='kfuse-knight' --docker-server 'us.gcr.io' --docker-username _json_key \
           --docker-email 'container-registry@mvp-demo-301906.iam.gserviceaccount.com' \
           --docker-password='"$(cat token.json)"'
   ```

```console
   type token.json | helm registry login -u _json_key  --password-stdin https://us-east-1-docker.pkg.dev
   $service_json = (Get-Content token.json).replace("\n", "").replace('"', '"')
   kubectl create secret docker-registry kfuse-image-pull-credentials --namespace=kfuse-knight --docker-server 'us.gcr.io' --docker-username _json_key --docker-email 'container-registry@mvp-demo-301906.iam.gserviceaccount.com' --docker-password=""$service_json""
   ```

2. Get the latest knight chart version.

```console
   helm upgrade --install knight oci://us-east-1-docker.pkg.dev/mvp-demo-301906/kfuse-helm/kfuse-knight --version=0.1.0-9688fac -n kfuse-knight
   ```

## Customizing the Metrics

You can customize the Kfuse-Knight helm values when extracting metrics from logs. This enables you to control the Knight protocols for tracing the necessary information, and to accurately tag it for generated metrics.

The `config` section of the helm values contains a section of what metrics to extract and how to tag them. You can customize them to fulfill your organization’s requirements. See [Extracting and tagging metrics](https://docs.kloudfuse.com/platform/3.2.5/agent-kfuse-knight/#tags).

The following example specifies what tags to include or exclude when emitting logs. Additionally:

- Specify exact field names.
- You can specify a Regex pattern.
- When specifying both includes and excludes, simply add the field names to each list.
- When using JSON formatting, you can extract subfields using the following format:
   
   ```console
   field_name$JSON$<json pointer>
   ```

Extracting and tagging metrics

```yaml
config:
  http:
    metrics:
      tags_include:
        - request_type
        - response_code
        - request_headers$JSON$/Accept
        - request_headers$JSON$/Host
      tags_exclude:
```

## Scraping Metrics

Knight exposes a Prometheus endpoint for its collected metrics.

|     |     |
| --- | --- |
|     | Recommendation<br>To automatically enrich the collected metrics with Cloud and Kubernetes labels, use the Datadog agent to scrape the metrics. |

In addition to the configurations specified in Collecting Data Using Datadog Agent, add the following configuration in the Datadog agent yaml file.
