canonical / canonical/script-exporter-operator

The charm should generate its own scrape jobs and forward them over `cos_agent`

Open
#57 1 comment 0 reactions 0 assignees View on GitHub
Status: Triage Type: Enhancement
Dominant language
Python
Stars
1
Forks
2
Avg merge
4h 2m
Merged PRs (30d)
1

Description

### Enhancement Proposal

The charm currently has a Juju config option called `prometheus_config_file`. This config option defines the The reason this option exists is so that there is a means for the collection of the time-series. However, this config option has to be manually created and supplied by the user currently. There is no reason why the charm shouldn't be able to do this ([BE does this itself](https://github.com/canonical/blackbox-exporter-operator/blob/92db10a57d493cd858312c1ba8cdc5597e02d232/src/charm.py#L270-L279)).
The feature would be something like
```
Feature: Use user-provided Prometheus scrape jobs
As a Juju operator
I want the charm to use my provided Prometheus configuration
So that I can fully control scrape job definitions

Scenario: prometheus_config_file option is set
GIVEN the `script-exporter` charm is deployed
AND the "prometheus_config_file" configuration option is set to a valid file path
AND the file contains valid Prometheus scrape job definitions
WHEN the charm is installed or upgraded
THEN the charm does not generate a default scrape configuration
AND the charm uses the scrape jobs defined in the provided file
AND the status is "active"
```
AND
```
Feature: Auto-generate Prometheus scrape jobs
As a Juju operator
I want the charm to generate scrape jobs automatically
So that Prometheus/Grafana Agent/Opentelemetry Collector can scrape the timeseries produced by script-exporter without providing a custom config file

Scenario: prometheus_config_file option is not set
GIVEN the Prometheus Script Exporter charm is deployed
AND the "prometheus_config_file" configuration option is not specified
WHEN the charm is installed or upgraded
THEN the charm generates a default Prometheus scrape configuration
AND the generated configuration contains a scrape job for the script exporter endpoint
AND the status is "active"
```
One minor note here is that the Prometheus config file should specify the name of the script that Script Exporter needs to run in its params. For example:
```
scrape_configs:
- job_name: 'script_example'
metrics_path: /probe
params:
**script: [example]**
prefix: [script]
static_configs:
- targets:
- 127.0.0.1

```

The question is, how should the charm know which script(s) to place there from the list of scripts present in the script file? The charm should ideally be able to grab the name of each script from the set config option.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the charm implementation and the linked blackbox-exporter-operator charm.py example, then trace how prometheus_config_file and the script configuration are handled. Define how script names are discovered and forwarded over cos_agent, preserving user-provided scrape jobs; done should cover both configuration paths and active status after install or upgrade.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus, python
Domain
observability-sre
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.