# OBI service discovery

The `executable_path`, `open_port`, `service_name`, and `service_namespace` top-level fields are key settings that help you configure OBI to instrument either a single service or a group of related services.

In some deployments, such as running Coralogix as a Kubernetes DaemonSet, you may need to monitor a broad range of services. The `discovery` section in the YAML configuration provides fine-grained control over which services Coralogix instruments.

For example, you can override service names and namespaces for different types of services.

## Services selection

| YAML Key     | Env Variable | Type            | Default |
| ------------ | ------------ | --------------- | ------- |
| `instrument` | N/A          | list of objects | (unset) |

Specify different selection rules for different services. You can also override metadata such as service name or namespace.

See the [Discovery services example](#discovery-services-example) section for more details.

## Exclude services

| YAML Key             | Env Variable | Type            | Default |
| -------------------- | ------------ | --------------- | ------- |
| `exclude_instrument` | N/A          | list of objects | (unset) |

Define services to exclude from instrumentation. This uses the same format as the `services` selection. Useful for skipping services like Prometheus.

## Default excluded services

| YAML Key                     | Env Variable | Type            | Default |
| ---------------------------- | ------------ | --------------- | ------- |
| `default_exclude_instrument` | N/A          | list of objects | \`(?:^  |

## Skip Go-specific tracers

| YAML Key                   | Env Variable                         | Type    | Default |
| -------------------------- | ------------------------------------ | ------- | ------- |
| `skip_go_specific_tracers` | `OTEL_EBPF_SKIP_GO_SPECIFIC_TRACERS` | boolean | false   |

Turns off detection of Go-specific telemetry. Coralogix falls back to generic instrumentation in this case.

## Language selection

New in v0.6.0

There is no top-level `language` key under `discovery`. Restrict instrumentation to specific programming languages in one of two ways:

- **As a selector inside an `instrument` entry**: set the `languages` glob on the entry. See [Selector properties](#selector-properties).
- **Globally via environment variable**: set `OTEL_EBPF_AUTO_TARGET_LANGUAGE` (glob). This applies to all discovered processes.

Supported values: `go`, `java`, `dotnet`, `python`, `ruby`, `nodejs`, `c`, `cpp`, `rust`. Use this to reduce overhead or limit instrumentation scope in mixed-language environments.

## Filter by PID

Changed in v0.7.0

| YAML Key      | Env Variable           | Type                                                                            | Default |
| ------------- | ---------------------- | ------------------------------------------------------------------------------- | ------- |
| `target_pids` | `OTEL_EBPF_TARGET_PID` | comma-separated list of integers or ranges (for example, `1234,5678,9000-9100`) | (unset) |

Restrict OBI to instrument only specific processes by their process IDs (PIDs). This is useful for targeted debugging or when you want to instrument a single process without broader service discovery.

`target_pids` can be set at the top level of the OBI config (applies globally) or as a selector inside an `instrument` entry (applies only to that entry).

From OBI v0.7.0+, the PID selection list is evaluated dynamically: PIDs added to the configuration are picked up at runtime, and PIDs removed from the list are detached without restarting OBI.

## Filter by command-line argument

New in v0.6.0

| YAML Key   | Env Variable | Type          | Default |
| ---------- | ------------ | ------------- | ------- |
| `cmd_args` | –            | string (glob) | (unset) |

Filter processes by their command-line arguments. Use this selector inside an `instrument` entry to distinguish between multiple instances of the same binary running with different arguments.

## Exclude OpenTelemetry-instrumented services

| YAML Key                                          | Env Variable                                                | Type    | Default |
| ------------------------------------------------- | ----------------------------------------------------------- | ------- | ------- |
| `exclude_otel_instrumented_services`              | `OTEL_EBPF_EXCLUDE_OTEL_INSTRUMENTED_SERVICES`              | boolean | true    |
| `exclude_otel_instrumented_services_span_metrics` | `OTEL_EBPF_EXCLUDE_OTEL_INSTRUMENTED_SERVICES_SPAN_METRICS` | boolean | false   |

Prevents Coralogix from monitoring services that already use OpenTelemetry SDKs to avoid duplicated telemetry. Turn this off if dual telemetry is acceptable.

## Discovery services example

Example YAML selecting two service groups:

```yaml
discovery:
  instrument:
    - exe_path: {worker,backend,frontend}
      namespace: MyApplication
    - exe_path: loadgen
      namespace: testing
      name: "TestLoadGenerator"
```

Coralogix instruments processes matching `exe_path` values. The `name` and `namespace` fields control the service's reported identity.

## Service name and namespace overrides

Each service entry accepts properties grouped by purpose:

1. **Name and namespace overrides**: `name`, `namespace`
1. **Selection criteria (selectors)**: everything else

### Name override

| YAML Key | Env Variable | Type   | Default   |
| -------- | ------------ | ------ | --------- |
| `name`   | –            | string | (derived) |

Sets the service name in telemetry. Deprecated in favor of automatic metadata extraction.

## Namespace override

| YAML Key    | Env Variable | Type   | Default            |
| ----------- | ------------ | ------ | ------------------ |
| `namespace` | –            | string | (derived or empty) |

Sets the service namespace in telemetry. Deprecated.

## Selector properties

| YAML Key               | Env Variable | Type                     | Default |
| ---------------------- | ------------ | ------------------------ | ------- |
| `open_ports`           | –            | string (ports)           | (unset) |
| `exe_path`             | –            | string (glob)            | (unset) |
| `languages`            | –            | string (glob)            | (unset) |
| `target_pids`          | –            | list of integers         | (unset) |
| `cmd_args`             | –            | string (glob)            | (unset) |
| `containers_only`      | –            | boolean                  | false   |
| `k8s_namespace`        | –            | string (glob)            | (unset) |
| `k8s_pod_name`         | –            | string (glob)            | (unset) |
| `k8s_deployment_name`  | –            | string (glob)            | (unset) |
| `k8s_replicaset_name`  | –            | string (glob)            | (unset) |
| `k8s_statefulset_name` | –            | string (glob)            | (unset) |
| `k8s_daemonset_name`   | –            | string (glob)            | (unset) |
| `k8s_owner_name`       | –            | string (glob)            | (unset) |
| `k8s_pod_labels`       | –            | map[string]string (glob) | (unset) |
| `k8s_pod_annotations`  | –            | map[string]string (glob) | (unset) |

Selectors can be combined within an entry. All conditions must match for a process to be instrumented.

Selectors support numeric comparison operators for fields like `open_ports`. For example, you can use `>8000` to match ports greater than 8000.

Example using labels:

```yaml
discovery:
  instrument:
    - k8s_namespace: frontend
      k8s_pod_labels:
        instrument: obi
```

## Kubernetes-specific name and namespace resolution

Coralogix automatically sets service name and namespace using Kubernetes metadata in this priority order:

1. `OTEL_RESOURCE_ATTRIBUTES` or `OTEL_SERVICE_NAME` environment variables
1. Pod annotations:
   - `resource.opentelemetry.io/service.name`
   - `resource.opentelemetry.io/service.namespace`
1. Pod labels:
   - `app.kubernetes.io/name`
   - `app.kubernetes.io/part-of`
1. Pod owner metadata (Deployment, ReplicaSet, StatefulSet, etc.)
1. Executable name

You can override default labels with YAML. In the OBI config, `kubernetes` is nested under `attributes`:

```yaml
attributes:
  kubernetes:
    resource_labels:
      service.name:
        - override-svc-name
        - app.kubernetes.io/name
      service.namespace:
        - override-svc-ns
        - app.kubernetes.io/part-of
```
