Skip to content

Commit

Permalink
add unit to tables and hide flag to es targets (#604)
Browse files Browse the repository at this point in the history
* add unit to tables and hide flag to es targets

* Update CHANGELOG.rst

---------

Co-authored-by: Gil Popilski <gilou@gils-mbp.lan>
  • Loading branch information
giloup933 and Gil Popilski authored Jul 12, 2023
1 parent 9660005 commit 2942349
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
==================

Expand Down
7 changes: 5 additions & 2 deletions grafanalib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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):
Expand All @@ -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
},
Expand Down
3 changes: 3 additions & 0 deletions grafanalib/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)))
Expand Down Expand Up @@ -407,6 +409,7 @@ def to_json_data(self):
'query': self.query,
'refId': self.refId,
'timeField': self.timeField,
'hide': self.hide,
}


Expand Down

0 comments on commit 2942349

Please sign in to comment.