Skip to content

Commit

Permalink
feat: add chain_id label to prometheus to improve alert monitoring (#…
Browse files Browse the repository at this point in the history
…68)

## Description

Fixes BDU-280
- Added `chain_id` label to prometheus’ `juno_last_indexed_height` metric

## Checklist
- [x] Targeted PR against correct branch.
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote unit tests.  
- [x] Re-reviewed `Files changed` in the Github PR explorer.
  • Loading branch information
MonikaCat authored and RiccardoM committed May 26, 2022
1 parent 2745377 commit 11ee7c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased
### Changes
- ([\#68](https://github.com/forbole/juno/pull/68)) Added `chain_id` label to prometheus to improve alert monitoring

## v3.2.0
### Changes
- ([\#61](https://github.com/forbole/juno/pull/61)) Updated v3 migration code to handle database users names with a hyphen
Expand Down
2 changes: 1 addition & 1 deletion logging/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var WorkerHeight = prometheus.NewGaugeVec(
Name: "juno_last_indexed_height",
Help: "Height of the last indexed block.",
},
[]string{"worker_index"},
[]string{"worker_index", "chain_id"},
)

// ErrorCount represents the Telemetry counter used to track the number of errors emitted
Expand Down
6 changes: 5 additions & 1 deletion parser/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func NewWorker(ctx *Context, queue types.HeightQueue, index int) Worker {
// given worker queue. Any failed job is logged and re-enqueued.
func (w Worker) Start() {
logging.WorkerCount.Inc()
nodeInfo, err := w.node.Genesis()
if err != nil {
w.logger.Error("error while getting genesis info from the node ", "err", err)
}

for i := range w.queue {
if err := w.ProcessIfNotExists(i); err != nil {
Expand All @@ -64,7 +68,7 @@ func (w Worker) Start() {
}()
}

logging.WorkerHeight.WithLabelValues(fmt.Sprintf("%d", w.index)).Set(float64(i))
logging.WorkerHeight.WithLabelValues(fmt.Sprintf("%d", w.index), nodeInfo.Genesis.ChainID).Set(float64(i))
}
}

Expand Down

0 comments on commit 11ee7c1

Please sign in to comment.