Skip to content

Commit

Permalink
fix traffic metric with faulty session log source
Browse files Browse the repository at this point in the history
  • Loading branch information
Sch8ill committed Nov 30, 2024
1 parent 91fd522 commit f0ca83c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ scrape_configs:
| name | description | labels | type |
|-------------------------------------|-------------------------------------------------------|--------------------|--------------|
| myst_node_bandwidth | Internet bandwidth of the node | id, name | mbit/s |
| myst_node_traffic | Traffic transferred by the node over the last 30 days | id, name, service, country | gigabytes |
| myst_node_traffic | Traffic transferred by the node over the last 30 days | id, name | gigabytes |
| myst_node_quality | Quality score assigned to the node | id, name | float |
| myst_node_service | whether a service on the node is running | id, name, service | boolean |
| myst_node_earnings | Earnings by service of node over the last 30 days | id, name, service | MYST |
Expand All @@ -76,6 +76,7 @@ scrape_configs:
| myst_node_earnings_unsettled | Unsettled earnings by node | id, name | MYST |
| myst_node_sessions | Number of sessions of the node over the last 30 days | id, name, service, country | int |
| myst_node_session_earings | Earnings by node, generated from session log | id, name, service, country | MYST |
| myst_node_session_traffic | Traffic served by node, generated from session log | id, name, service, country | gigabyte |
| myst_node_session_durations | Total duration of sessions over the last 30 days | id, name, service, country | seconds |
| myst_token_price | Current price of the MYST token | currency | EUR/USD |
| myst_node_location | Location of the node | id, name, location | country code |
Expand Down
16 changes: 11 additions & 5 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var nodeBandwidth = prometheus.NewGaugeVec(prometheus.GaugeOpts{

var nodeTraffic = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "myst_node_traffic",
Help: "Traffic transferred by the node by service and country over the last 30 days",
}, []string{"id", "name", "service", "country"})
Help: "Traffic transferred by the node over the last 30 days",
}, []string{"id", "name"})

var nodeUserID = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "myst_node_user_id",
Expand Down Expand Up @@ -181,6 +181,11 @@ var nodeSessionEarnings = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Help: "Earnings by node, service and country generated from session log",
}, []string{"id", "name", "service", "country"})

var nodeSessionTraffic = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "myst_node_session_traffic",
Help: "Traffic served by node by service and country, generated from session log",
}, []string{"id", "name", "service", "country"})

var nodeSessionDurations = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "myst_node_session_durations",
Help: "Total duration of sessions of the node by service and country over the last 30 days",
Expand Down Expand Up @@ -212,8 +217,8 @@ func init() {
nodeAvailableAt, nodeCreatedAt, nodeUpdatedAt, nodeDeleted, nodeLauncherVersion, nodeIPTagged,
nodeMonitoringFailed, nodeMonitoringFailedLastAt, nodeOnline, nodeOnlineLastAt, nodeStatusCreatedAt,
nodeStatusUpdatedAt, nodeIPCategory, nodeLocation, nodeQuality, nodeService, nodeMonitoringStatus,
nodeEarnings, nodeSessions, nodeSessionEarnings, nodeSessionDurations, nodeLifetimeEarnings,
nodeSettledEarnings, nodeUnsettledEarnings, mystPrice)
nodeEarnings, nodeSessions, nodeSessionEarnings, nodeSessionTraffic, nodeSessionDurations,
nodeLifetimeEarnings, nodeSettledEarnings, nodeUnsettledEarnings, mystPrice)
}

func NodeCount(n int) {
Expand Down Expand Up @@ -245,7 +250,7 @@ func NodeSessions(id string, name string, sessions []node.Session) {

for f, total := range sessionCount {
nodeSessions.WithLabelValues(id, name, f.service, f.country).Set(float64(total))
nodeTraffic.WithLabelValues(id, name, f.service, f.country).Set(traffic[f])
nodeSessionTraffic.WithLabelValues(id, name, f.service, f.country).Set(traffic[f])
nodeSessionDurations.WithLabelValues(id, name, f.service, f.country).Set(float64(durations[f].Seconds()))
nodeSessionEarnings.WithLabelValues(id, name, f.service, f.country).Set(earnings[f])
}
Expand Down Expand Up @@ -299,6 +304,7 @@ func NodeLifetimeEarnings(id string, name string, earnings node.LifetimeEarnings

func NodeTotals(id string, name string, t *totals.Totals) {
nodeBandwidth.WithLabelValues(id, name).Set(t.BandwidthTotal)
nodeTraffic.WithLabelValues(id, name).Set(t.TrafficTotal * 1024)
}

func MystPrices(prices map[string]float64) {
Expand Down

0 comments on commit f0ca83c

Please sign in to comment.