Skip to content

Commit ae2c56c

Browse files
committed
use a unique name for prometheus to aggregate
metrics
1 parent ea1eda9 commit ae2c56c

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

batchtools/br.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ def run(args: argparse.Namespace):
221221

222222
IN_PROGRESS.labels(**labels, result=result_phase).dec()
223223

224-
# 👇 Create a grouping key unique to this job run
225224
group = {
226225
"instance": PROMETHEUS_INSTANCE, # e.g. "ope-test"
227-
"job_name": "job", # e.g. "job-none-b799d46a6f995a9d8d58b6aff76abefc"
226+
"job_name": job_name # e.g. "job-none-b799d46a6f995a9d8d58b6aff76abefc"
228227
}
229228

230229
push_registry_text(grouping_key=group)

batchtools/prom_metrics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
Gauge,
1414
generate_latest,
1515
CONTENT_TYPE_LATEST,
16-
pushadd_to_gateway, # <-- add this
16+
pushadd_to_gateway,
1717
)
1818

1919
LONG_JOB_BUCKETS = (1, 2, 5, 10, 20, 30, 60, 120, 180, 300, 600, 900, float("inf"))
@@ -141,8 +141,6 @@ def generate_metrics_text() -> tuple[str, str]:
141141
payload = generate_latest(registry)
142142
return payload.decode("utf-8"), CONTENT_TYPE_LATEST
143143

144-
from prometheus_client import pushadd_to_gateway, delete_from_gateway # add delete if you want cleanup
145-
146144
def push_registry_text(grouping_key: dict[str, str] | None = None) -> None:
147145
if not PUSHGATEWAY_ADDR:
148146
body, _ = generate_metrics_text()

0 commit comments

Comments
 (0)