Skip to content

Commit

Permalink
Add new metric: file size of documents per vault / tag (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasuillard authored Sep 23, 2024
1 parent b2e6880 commit 4299151
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "onepassword-exporter"
version = "0.2.1"
version = "0.3.0"
edition = "2021"

[dependencies]
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,22 @@ Here is full example of available metrics, with all metrics enabled:
op_account_current{created_at="2023-03-19T05:06:27Z",domain="my",id="??????????????????????????",name="**********",state="ACTIVE",type="FAMILY"} 1
# HELP op_document_count_per_tag Number of documents per tag.
# TYPE op_document_count_per_tag gauge
op_document_count_per_tag{tag="test"} 1
op_document_count_per_tag{tag="test"} 4
# HELP op_document_count_per_vault Number of documents per vault.
# TYPE op_document_count_per_vault gauge
op_document_count_per_vault{vault="36vhq4xz3r6hnemzadk33evi4a"} 1
op_document_count_per_vault{vault="36vhq4xz3r6hnemzadk33evi4a"} 4
# HELP op_document_count_total Total number of documents.
# TYPE op_document_count_total gauge
op_document_count_total 1
op_document_count_total 4
# HELP op_document_file_size_per_tag_bytes Size of file in documents per tag, in bytes.
# TYPE op_document_file_size_per_tag_bytes gauge
op_document_file_size_per_tag_bytes{tag="test"} 10494986
# HELP op_document_file_size_per_vault_bytes Size of file in documents per vault, in bytes.
# TYPE op_document_file_size_per_vault_bytes gauge
op_document_file_size_per_vault_bytes{vault="36vhq4xz3r6hnemzadk33evi4a"} 10494986
# HELP op_exporter_buildinfo Build information of this exporter.
# TYPE op_exporter_buildinfo gauge
op_exporter_buildinfo{version="0.2.0"} 1
op_exporter_buildinfo{version="0.3.0"} 1
# HELP op_group_count_total Total number of groups.
# TYPE op_group_count_total gauge
op_group_count_total 4
Expand Down
125 changes: 121 additions & 4 deletions examples/grafana-dashboard/dashboard.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
{
"__inputs": [],
"__elements": {},
"__requires": [
{
"type": "panel",
"id": "gauge",
"name": "Gauge",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "11.2.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
},
{
"type": "panel",
"id": "table",
"name": "Table",
"version": ""
},
{
"type": "panel",
"id": "timeseries",
"name": "Time series",
"version": ""
}
],
"annotations": {
"list": [
{
Expand All @@ -19,6 +59,7 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": null,
"links": [],
"panels": [
{
Expand Down Expand Up @@ -1793,7 +1834,7 @@
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisLabel": "op_document_count_per_vault",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
Expand Down Expand Up @@ -1837,7 +1878,28 @@
]
}
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "op_document_file_size_per_vault_bytes"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "right"
},
{
"id": "custom.axisLabel",
"value": "op_document_file_size_per_vault_bytes"
},
{
"id": "unit",
"value": "decbytes"
}
]
}
]
},
"gridPos": {
"h": 10,
Expand Down Expand Up @@ -1875,6 +1937,23 @@
"range": true,
"refId": "A",
"useBackend": false
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "op_document_file_size_per_vault_bytes",
"fullMetaSearch": false,
"hide": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "{{vault}}",
"range": true,
"refId": "B",
"useBackend": false
}
],
"title": "Documents per Vault",
Expand Down Expand Up @@ -2332,7 +2411,7 @@
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisLabel": "op_document_count_per_tag",
"axisPlacement": "auto",
"barAlignment": 0,
"barWidthFactor": 0.6,
Expand Down Expand Up @@ -2376,7 +2455,28 @@
]
}
},
"overrides": []
"overrides": [
{
"matcher": {
"id": "byName",
"options": "op_document_file_size_per_tag_bytes"
},
"properties": [
{
"id": "custom.axisPlacement",
"value": "right"
},
{
"id": "custom.axisLabel",
"value": "op_document_file_size_per_tag_bytes"
},
{
"id": "unit",
"value": "decbytes"
}
]
}
]
},
"gridPos": {
"h": 10,
Expand Down Expand Up @@ -2414,6 +2514,23 @@
"range": true,
"refId": "A",
"useBackend": false
},
{
"datasource": {
"type": "prometheus",
"uid": "${datasource}"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "op_document_file_size_per_tag_bytes",
"fullMetaSearch": false,
"hide": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "{{tag}}",
"range": true,
"refId": "B",
"useBackend": false
}
],
"title": "Documents per Tag",
Expand Down
2 changes: 2 additions & 0 deletions examples/grafana-dashboard/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
ports:
- ${GRAFANA_HOST:-127.0.0.1}:${GRAFANA_PORT:-3000}:3000
volumes:
- grafana-data:/var/lib/grafana
- ./dashboard.json:/var/lib/grafana/dashboards/dashboard.json
configs:
- source: datasource.yaml
Expand Down Expand Up @@ -87,4 +88,5 @@ configs:
- onepassword-exporter:9999
volumes:
grafana-data:
prometheus-data:
14 changes: 10 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,22 @@ mod tests {
op_account_current{created_at="2023-03-19T05:06:27Z",domain="my",id="??????????????????????????",name="**********",state="ACTIVE",type="FAMILY"} 1
# HELP op_document_count_per_tag Number of documents per tag.
# TYPE op_document_count_per_tag gauge
op_document_count_per_tag{tag="test"} 1
op_document_count_per_tag{tag="test"} 4
# HELP op_document_count_per_vault Number of documents per vault.
# TYPE op_document_count_per_vault gauge
op_document_count_per_vault{vault="36vhq4xz3r6hnemzadk33evi4a"} 1
op_document_count_per_vault{vault="36vhq4xz3r6hnemzadk33evi4a"} 4
# HELP op_document_count_total Total number of documents.
# TYPE op_document_count_total gauge
op_document_count_total 1
op_document_count_total 4
# HELP op_document_file_size_per_tag_bytes Size of file in documents per tag, in bytes.
# TYPE op_document_file_size_per_tag_bytes gauge
op_document_file_size_per_tag_bytes{tag="test"} 10494986
# HELP op_document_file_size_per_vault_bytes Size of file in documents per vault, in bytes.
# TYPE op_document_file_size_per_vault_bytes gauge
op_document_file_size_per_vault_bytes{vault="36vhq4xz3r6hnemzadk33evi4a"} 10494986
# HELP op_exporter_buildinfo Build information of this exporter.
# TYPE op_exporter_buildinfo gauge
op_exporter_buildinfo{version="0.2.0"} 1
op_exporter_buildinfo{version="0.3.0"} 1
# HELP op_group_count_total Total number of groups.
# TYPE op_group_count_total gauge
op_group_count_total 4
Expand Down
2 changes: 1 addition & 1 deletion src/metrics_collector/build_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod tests {
// Assert
assert_eq!(
OP_EXPORTER_BUILDINFO
.get_metric_with_label_values(&["0.2.0"])?
.get_metric_with_label_values(&["0.3.0"])?
.get(),
1
);
Expand Down
Loading

0 comments on commit 4299151

Please sign in to comment.