From 29423493ccdb80941a4b295d22e8ec89cd6c41df Mon Sep 17 00:00:00 2001 From: giloup933 Date: Wed, 12 Jul 2023 09:57:32 -0500 Subject: [PATCH] add unit to tables and hide flag to es targets (#604) * add unit to tables and hide flag to es targets * Update CHANGELOG.rst --------- Co-authored-by: Gil Popilski --- CHANGELOG.rst | 3 +++ grafanalib/core.py | 7 +++++-- grafanalib/elasticsearch.py | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) 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) ================== diff --git a/grafanalib/core.py b/grafanalib/core.py index 038ae912..67a08839 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -3196,6 +3196,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)) @@ -3207,7 +3208,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): @@ -3229,8 +3231,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, }