Skip to content

Commit 37e8c8c

Browse files
committed
Send flavor resources as value metadata
This addresses an issue where the resources dimension could contain a string with prohibited characters, for example: "VCPU:64, MEMORY_MB:393216, DISK_GB:110, None". This change moves the flavor resource string to the value_meta field which has fewer restrictions over the content. If we later want to index resources as a function of the flavor resource fields, for example CPU count, we could add those as separate dimensions on the metric.
1 parent d0297e2 commit 37e8c8c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

os_capacity/commands/commands.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ def take_action(self, parsed_args):
5959
free = group[3]
6060
metrics_to_send.append(metrics.Metric(
6161
name="resources.total", value=total,
62-
dimensions={"flavor": flavors, "resources": resources}))
62+
value_meta={"flavor_resources": resources},
63+
dimensions={"flavor": flavors}))
6364
metrics_to_send.append(metrics.Metric(
6465
name="resources.used", value=used,
65-
dimensions={"flavor": flavors, "resources": resources}))
66+
value_meta={"flavor_resources": resources},
67+
dimensions={"flavor": flavors}))
6668
metrics_to_send.append(metrics.Metric(
6769
name="resources.free", value=free,
68-
dimensions={"flavor": flavors, "resources": resources}))
70+
value_meta={"flavor_resources": resources},
71+
dimensions={"flavor": flavors}))
6972
metrics.send_metrics(self.app.monitoring_client, metrics_to_send)
7073

7174
return (

os_capacity/data/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import time
1818

1919
Metric = collections.namedtuple(
20-
"Metric", ("name", "value", "dimensions"))
20+
"Metric", ("name", "value", "value_meta", "dimensions"))
2121

2222
SEND_METRICS = 'OS_CAPACITY_SEND_METRICS' in os.environ
2323

@@ -33,7 +33,7 @@ def send_metrics(monitoring_client, metrics):
3333
"name": "os_capacity.%s" % metric.name,
3434
"value": float(metric.value),
3535
"timestamp": timestamp,
36-
"value_meta": None,
36+
"value_meta": metric.value_meta,
3737
"dimensions": metric.dimensions,
3838
})
3939
response = monitoring_client.post("/metrics", json=formatted_metrics)

0 commit comments

Comments
 (0)