canonical / canonical/cos-proxy-operator

remove composite_key duplication in nrpe_lookup table

Open
#60 1 comment 0 reactions 0 assignees View on GitHub
Priority: High Status: Triage Type: Bug
Dominant language
Python
Stars
3
Forks
12
PR merge metrics
No merged PRs in 30d

Description

### Bug Description

Once **vector** is started when relating to **nrpe** (either after #59 is resolved or by additionally deploying **filebeat**), the file `/etc/vector/nrpe_lookup.csv` contains duplicate lines for composite keys.

If you `juju ssh cos-proxy/0` you would see that

```bash
ubuntu@juju-142d1e-0:~$ cat /etc/vector/nrpe_lookup.csv
composite_key,juju_application,juju_unit,command,ipaddr
10.211.43.179_check_conntrack,ubuntu,ubuntu/0,check_conntrack,10.211.43.179
10.211.43.179_check_systemd_scopes,ubuntu,ubuntu/0,check_systemd_scopes,10.211.43.179
10.211.43.179_check_reboot,ubuntu,ubuntu/0,check_reboot,10.211.43.179
10.211.43.179_check_conntrack,ubuntu,ubuntu/0,check_conntrack,10.211.43.179
10.211.43.179_check_systemd_scopes,ubuntu,ubuntu/0,check_systemd_scopes,10.211.43.179
10.211.43.179_check_reboot,ubuntu,ubuntu/0,check_reboot,10.211.43.179
```

This duplication causes the log format to be weird and to not be correctly parsed from Grafana when using the Loki datasource.
The code responsible for this duplication should be [here](https://github.com/canonical/cos-proxy-operator/blob/main/lib/charms/vector/v0/vector.py#L241).

### To Reproduce

**machine model**
1. `juju deploy ubuntu`
2. `juju deploy nrpe`
3. `juju deploy cos-proxy`
4. `juju relate nrpe ubuntu`
5. `juju relate cos-proxy nrpe`

**k8s model**
1. `juju deploy cos-lite --channel=edge`
2. cross-model relate *cos-proxy* to *loki*

### Environment

```
∮ microk8s version
MicroK8s v1.26.1 revision 4596
∮ juju --version
3.1.0-genericlinux-amd64
∮ lxd --version
5.12
```

### Relevant log output

```shell
-
```

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at lib/charms/vector/v0/vector.py around line 241 and inspect how /etc/vector/nrpe_lookup.csv is generated when NRPE and Filebeat or Vector are related. Reproduce with the listed Juju deployments, then verify the CSV contains one row per composite key and that the resulting logs parse correctly through the Loki datasource.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, observability-sre
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.