Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add chain_id label to prometheus to improve alert monitoring #68

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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