From f84af2890607ed3f4549d36c8ce8b03805261bb9 Mon Sep 17 00:00:00 2001 From: Gil Popilski Date: Fri, 16 Jun 2023 23:38:50 -0500 Subject: [PATCH 1/2] add unit to tables and hide flag to es targets --- grafanalib/core.py | 7 +++++-- grafanalib/elasticsearch.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/grafanalib/core.py b/grafanalib/core.py index ed109763..4d005ecd 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -3194,6 +3194,7 @@ class Table(Panel): :param mappings: To assign colors to boolean or string values, use Value mappings :param overrides: To override the base characteristics of certain data :param showHeader: Show the table header + :param unit: units """ align = attr.ib(default='auto', validator=instance_of(str)) @@ -3205,7 +3206,8 @@ class Table(Panel): mappings = attr.ib(default=attr.Factory(list)) overrides = attr.ib(default=attr.Factory(list)) showHeader = attr.ib(default=True, validator=instance_of(bool)) - span = attr.ib(default=6) + span = attr.ib(default=6), + unit = attr.ib(default='', validator=instance_of(str)) @classmethod def with_styled_columns(cls, columns, styles=None, **kwargs): @@ -3227,8 +3229,9 @@ def to_json_data(self): 'custom': { 'align': self.align, 'displayMode': self.displayMode, - 'filterable': self.filterable + 'filterable': self.filterable, }, + 'unit': self.unit }, 'overrides': self.overrides }, diff --git a/grafanalib/elasticsearch.py b/grafanalib/elasticsearch.py index 35f1a9d4..bf4cb297 100644 --- a/grafanalib/elasticsearch.py +++ b/grafanalib/elasticsearch.py @@ -363,6 +363,7 @@ class ElasticsearchTarget(object): :param query: query :param refId: target reference id :param timeField: name of the elasticsearch time field + :param hide: show/hide the target result in the final panel display """ alias = attr.ib(default=None) @@ -373,6 +374,7 @@ class ElasticsearchTarget(object): query = attr.ib(default="", validator=instance_of(str)) refId = attr.ib(default="", validator=instance_of(str)) timeField = attr.ib(default="@timestamp", validator=instance_of(str)) + hide = attr.ib(default=False, validator=instance_of(bool)) def _map_bucket_aggs(self, f): return attr.evolve(self, bucketAggs=list(map(f, self.bucketAggs))) @@ -407,6 +409,7 @@ def to_json_data(self): 'query': self.query, 'refId': self.refId, 'timeField': self.timeField, + 'hide': self.hide, } From 963e3774c3637f414e8ef96b5df9b0898cf9c998 Mon Sep 17 00:00:00 2001 From: Gil Popilski Date: Sat, 17 Jun 2023 00:06:29 -0500 Subject: [PATCH 2/2] Update CHANGELOG.rst --- CHANGELOG.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7c480404..f9486255 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,9 @@ Changelog .. _`Bar_Chart`: https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/bar-chart/ .. _`RateMetricAgg`: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-rate-aggregation.html +* Added unit parameter to the Table class in core +* Added a hide parameter to ElasticsearchTarget + 0.7.0 (2022-10-02) ==================