Skip to content

Commit

Permalink
fix(analytics): add total_byte_cost to ledger size analytics (#1028)
Browse files Browse the repository at this point in the history
* Add `total_byte_cost` to ledger size analytics

* PR suggestions

* Cleanup

* Add sort

* Fix rent calculation

* rework storage deposit value

* Clippy and revert dashboard names

* Revert dashboard

* Fix value computation

* add sdruc inner value

* Refactor

* Add panel

* in parallel and fmt

* Remove format

Co-authored-by: Jochen Görtler <[email protected]>
Co-authored-by: Jochen Görtler <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2023
1 parent caec5a0 commit dcda7d6
Show file tree
Hide file tree
Showing 5 changed files with 285 additions and 92 deletions.
159 changes: 144 additions & 15 deletions docker/assets/grafana/dashboards/analytics_dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@
"h": 9,
"w": 12,
"x": 12,
"y": 27
"y": 36
},
"id": 63,
"options": {
Expand Down Expand Up @@ -1441,7 +1441,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 36
"y": 45
},
"id": 59,
"panels": [],
Expand Down Expand Up @@ -1511,7 +1511,7 @@
"h": 9,
"w": 12,
"x": 0,
"y": 37
"y": 46
},
"id": 22,
"options": {
Expand Down Expand Up @@ -1695,7 +1695,7 @@
"h": 9,
"w": 12,
"x": 12,
"y": 37
"y": 46
},
"id": 60,
"options": {
Expand Down Expand Up @@ -1804,7 +1804,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 46
"y": 55
},
"id": 49,
"panels": [],
Expand Down Expand Up @@ -1873,7 +1873,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 47
"y": 56
},
"id": 51,
"options": {
Expand Down Expand Up @@ -2038,7 +2038,7 @@
"h": 8,
"w": 12,
"x": 12,
"y": 47
"y": 56
},
"id": 61,
"options": {
Expand Down Expand Up @@ -2165,7 +2165,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 55
"y": 64
},
"id": 31,
"panels": [],
Expand Down Expand Up @@ -2235,7 +2235,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 56
"y": 65
},
"id": 33,
"options": {
Expand Down Expand Up @@ -2302,6 +2302,135 @@
"title": "Unclaimed Tokens",
"type": "timeseries"
},
{
"datasource": {
"type": "influxdb",
"uid": "PE5723DBC504634E6"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 15,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "stepBefore",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "SMR"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 65
},
"id": 64,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"targets": [
{
"alias": "Return Amount",
"datasource": {
"type": "influxdb",
"uid": "PE5723DBC504634E6"
},
"groupBy": [
{
"params": [
"$aggregation_interval"
],
"type": "time"
},
{
"params": [
"null"
],
"type": "fill"
}
],
"measurement": "stardust_unlock_conditions",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"storage_deposit_return_inner_value"
],
"type": "field"
},
{
"params": [],
"type": "last"
},
{
"params": [
" / 1000000"
],
"type": "math"
}
]
],
"tags": []
}
],
"title": "Amount in Storage Deposit Return Unlock Condition",
"type": "timeseries"
},
{
"datasource": {
"type": "influxdb",
Expand Down Expand Up @@ -2365,8 +2494,8 @@
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 56
"x": 0,
"y": 73
},
"id": 36,
"options": {
Expand Down Expand Up @@ -2433,7 +2562,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 64
"y": 81
},
"id": 29,
"panels": [],
Expand Down Expand Up @@ -2502,7 +2631,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 65
"y": 82
},
"id": 39,
"options": {
Expand Down Expand Up @@ -2649,7 +2778,7 @@
"h": 8,
"w": 12,
"x": 12,
"y": 65
"y": 82
},
"id": 41,
"options": {
Expand Down Expand Up @@ -2704,7 +2833,7 @@
},
{
"params": [
" * 100 / 1000000"
" / 1000000"
],
"type": "math"
}
Expand Down
23 changes: 11 additions & 12 deletions src/db/collections/analytics/influx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,9 @@ impl From<Measurement> for influxdb::WriteQuery {
),
Measurement::LedgerSizeAnalytics(m) => m
.prepare_query("stardust_ledger_size")
.add_field(
"total_storage_deposit_value",
m.inner.total_storage_deposit_value.to_string().parse::<u64>().unwrap(),
)
.add_field(
"total_key_bytes",
m.inner.total_key_bytes.to_string().parse::<u64>().unwrap(),
)
.add_field(
"total_data_bytes",
m.inner.total_data_bytes.to_string().parse::<u64>().unwrap(),
),
.add_field("total_key_bytes", m.inner.total_key_bytes)
.add_field("total_data_bytes", m.inner.total_data_bytes)
.add_field("total_storage_deposit_value", m.inner.total_storage_deposit_value),
Measurement::OutputActivityAnalytics(m) => m
.prepare_query("stardust_output_activity")
.add_field("alias_created_count", m.inner.alias.created_count)
Expand Down Expand Up @@ -110,6 +101,14 @@ impl From<Measurement> for influxdb::WriteQuery {
.add_field(
"storage_deposit_return_value",
m.inner.storage_deposit_return_value.to_string().parse::<u64>().unwrap(),
)
.add_field(
"storage_deposit_return_inner_value",
m.inner
.storage_deposit_return_inner_value
.to_string()
.parse::<u64>()
.unwrap(),
),
}
}
Expand Down
Loading

0 comments on commit dcda7d6

Please sign in to comment.