diff --git a/cron/example.sh b/cron/example.sh old mode 100644 new mode 100755 diff --git a/cron/grafana_dashboard.json b/cron/grafana_dashboard.json index d47d95a..75fd35a 100644 --- a/cron/grafana_dashboard.json +++ b/cron/grafana_dashboard.json @@ -407,7 +407,7 @@ "error": "", "group": true, "hide": false, - "metric": "os_capacity.usage.count", + "metric": "os_capacity.usage.user.count", "period": "300", "refId": "A" } @@ -502,7 +502,7 @@ ], "error": "", "group": true, - "metric": "os_capacity.usage.days.count", + "metric": "os_capacity.usage.user.days.count", "period": "300", "refId": "A" } diff --git a/os_capacity/commands/commands.py b/os_capacity/commands/commands.py index 314d0e5..5f04d6a 100644 --- a/os_capacity/commands/commands.py +++ b/os_capacity/commands/commands.py @@ -59,13 +59,16 @@ def take_action(self, parsed_args): free = group[3] metrics_to_send.append(metrics.Metric( name="resources.total", value=total, - dimensions={"flavor": flavors, "resources": resources})) + value_meta={"flavor_resources": resources}, + dimensions={"flavor": flavors})) metrics_to_send.append(metrics.Metric( name="resources.used", value=used, - dimensions={"flavor": flavors, "resources": resources})) + value_meta={"flavor_resources": resources}, + dimensions={"flavor": flavors})) metrics_to_send.append(metrics.Metric( name="resources.free", value=free, - dimensions={"flavor": flavors, "resources": resources})) + value_meta={"flavor_resources": resources}, + dimensions={"flavor": flavors})) metrics.send_metrics(self.app.monitoring_client, metrics_to_send) return ( diff --git a/os_capacity/data/metrics.py b/os_capacity/data/metrics.py index 21f07a5..487ef1f 100644 --- a/os_capacity/data/metrics.py +++ b/os_capacity/data/metrics.py @@ -17,7 +17,7 @@ import time Metric = collections.namedtuple( - "Metric", ("name", "value", "dimensions")) + "Metric", ("name", "value", "value_meta", "dimensions")) SEND_METRICS = 'OS_CAPACITY_SEND_METRICS' in os.environ @@ -33,7 +33,7 @@ def send_metrics(monitoring_client, metrics): "name": "os_capacity.%s" % metric.name, "value": float(metric.value), "timestamp": timestamp, - "value_meta": None, + "value_meta": metric.value_meta, "dimensions": metric.dimensions, }) response = monitoring_client.post("/metrics", json=formatted_metrics) diff --git a/os_capacity/utils.py b/os_capacity/utils.py index b2d2fcb..216f3f7 100644 --- a/os_capacity/utils.py +++ b/os_capacity/utils.py @@ -241,16 +241,18 @@ def get_key(allocation): if key_name: dimensions[name_key] = key_name - dimensions['usage_summary'] = usage - dimensions['version'] = 2.0 + value_meta = {'usage_summary': usage} + dimensions['version'] = '2.0' metrics_to_send.append(metrics.Metric( name="usage.%s.count" % group_by, value=grouped_usage['Count'], + value_meta=value_meta, dimensions=dimensions)) metrics_to_send.append(metrics.Metric( name="usage.%s.days.count" % group_by, value=grouped_usage_days['Count'], + value_meta=value_meta, dimensions=dimensions)) # Sort my largest current usage first