Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit to tables and hide flag to es targets #604

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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))
Expand All @@ -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):
Expand All @@ -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
},
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