Skip to content

Commit

Permalink
Merge pull request #18 from strava/needful/sync_with_upstream
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
Fluxx authored Sep 23, 2024
2 parents df4596b + ec4163c commit d4c5405
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 79 deletions.
31 changes: 28 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,47 @@
Changelog
=========

<<<<<<< HEAD
0.x.x (?)
==================

* Added ...
* Add `QueryMode` parameter in CloudwatchMetricsTarget
* Added support `alias` via the `legendFormat` option for `Target`
* Added `neutral` option for `GaugePanel` (supported by Grafana 9.3.0 - https://github.com/grafana/grafana/discussions/38273)
* Added support `alias` via the `legendFormat` option for `Target`
* **Breaking change:** Fixed spelling errors for temperature units, corrected 'CELSUIS' to 'CELSIUS' and 'FARENHEIT' to 'FAHRENHEIT'.
* Added ``tooltipSort`` parameter to PieChartv2 panel
* Fix mappings for Table
* Added support for AWS Cross-Account in CloudwatchMetricsTarget
* Added `LokiTarget`

0.7.1 2024-01-12
================

* Extended DashboardLink to support links to dashboards and urls, as per the docs_

.. _`docs`: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/manage-dashboard-links/#dashboard-links

* Fix default options for Heatmap
* Add Unit option for Graph panel
* Added Minimum option for Timeseries
* Added Maximum option for Timeseries
* Added Number of decimals displays option for Timeseries
* Added Bar_Chart_ panel support
* Extended SqlTarget to support parsing queries from files
* Fix AlertCondition backwards compatibility (``useNewAlerts`` default to ``False``)
* Added RateMetricAgg_ for ElasticSearch
* added axisSoftMin and axisSoftMax options for TimeSeries
* Added support for Azure Data Explorer datasource plugin (https://github.com/grafana/azure-data-explorer-datasource)
* Added ``sortBy`` parameter to Table panel
* Added ``tooltipSort`` parameter to TimeSeries panel
* Added unit parameter to the Table class in core
* Added a hide parameter to ElasticsearchTarget
* Fix value literal GAUGE_CALC_TOTAL to sum instead of total
* Fix `BarGauge` orientation validation to accept `'auto'`

.. _`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


0.7.0 (2022-10-02)
==================

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Support
This library is in its very early stages. We'll probably make changes that
break backwards compatibility, although we'll try hard not to.

grafanalib works with Python 3.6 through 3.10.
grafanalib works with Python 3.6 through 3.11.

Developing
==========
Expand Down
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sphinx == 6.1.3
sphinx_rtd_theme == 1.2.2
sphinx == 7.4.7
sphinx_rtd_theme == 2.0.0
41 changes: 41 additions & 0 deletions grafanalib/azuredataexplorer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Helpers to create Azure Data Explorer specific Grafana queries."""

import attr

TIME_SERIES_RESULT_FORMAT = 'time_series'
TABLE_RESULT_FORMAT = 'table'
ADX_TIME_SERIES_RESULT_FORMAT = 'time_series_adx_series'


@attr.s
class AzureDataExplorerTarget(object):
"""
Generates Azure Data Explorer target JSON structure.
Link to Azure Data Explorer datasource Grafana plugin:
https://grafana.com/grafana/plugins/grafana-azure-data-explorer-datasource/
Azure Data Explorer docs on query language (KQL):
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/
:param database: Database to execute query on
:param query: Query in Kusto Query Language (KQL)
:param resultFormat: Output format of the query result
:param alias: legend alias
:param refId: target reference id
"""

database = attr.ib(default="")
query = attr.ib(default="")
resultFormat = attr.ib(default=TIME_SERIES_RESULT_FORMAT)
alias = attr.ib(default="")
refId = attr.ib(default="")

def to_json_data(self):
return {
'database': self.database,
'query': self.query,
'resultFormat': self.resultFormat,
'alias': self.alias,
'refId': self.refId
}
15 changes: 12 additions & 3 deletions grafanalib/cloudwatch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Helpers to create Cloudwatch-specific Grafana queries."""

import attr

from attr.validators import instance_of

from grafanalib.core import Target


Expand All @@ -22,6 +22,8 @@ class CloudwatchMetricsTarget(Target):
:param expression: Cloudwatch Metric math expressions
:param id: unique id
:param matchExact: Only show metrics that exactly match all defined dimension names.
:param account: AWS Account where Cloudwatch is used
:param accountId: AWS Account ID where Cloudwatch is used
:param metricName: Cloudwatch metric name
:param namespace: Cloudwatch namespace
:param period: Cloudwatch data period
Expand All @@ -31,12 +33,16 @@ class CloudwatchMetricsTarget(Target):
:param statistic: Cloudwatch mathematic statistic
:param hide: controls if given metric is displayed on visualization
:param datasource: Grafana datasource name
:param queryMode: queryMode for cloudwatch metric request
"""

alias = attr.ib(default="")
dimensions = attr.ib(factory=dict, validator=instance_of(dict))
expression = attr.ib(default="")
id = attr.ib(default="")
matchExact = attr.ib(default=True, validator=instance_of(bool))
account = attr.ib(default="")
accountId = attr.ib(default="")
metricName = attr.ib(default="")
namespace = attr.ib(default="")
period = attr.ib(default="")
Expand All @@ -46,15 +52,17 @@ class CloudwatchMetricsTarget(Target):
statistic = attr.ib(default="Average")
hide = attr.ib(default=False, validator=instance_of(bool))
datasource = attr.ib(default=None)
queryMode = attr.ib(default="")

def to_json_data(self):

return {
"alias": self.alias,
"dimensions": self.dimensions,
"expression": self.expression,
"id": self.id,
"matchExact": self.matchExact,
"account": self.account,
"accountId": self.accountId,
"metricName": self.metricName,
"namespace": self.namespace,
"period": self.period,
Expand All @@ -64,6 +72,7 @@ def to_json_data(self):
"statistic": self.statistic,
"hide": self.hide,
"datasource": self.datasource,
"queryMode": self.queryMode,
}


Expand All @@ -88,6 +97,7 @@ class CloudwatchLogsInsightsTarget(Target):
:param hide: controls if given metric is displayed on visualization
:param datasource: Grafana datasource name
"""

expression = attr.ib(default="")
id = attr.ib(default="")
logGroupNames = attr.ib(factory=list, validator=instance_of(list))
Expand All @@ -99,7 +109,6 @@ class CloudwatchLogsInsightsTarget(Target):
datasource = attr.ib(default=None)

def to_json_data(self):

return {
"expression": self.expression,
"id": self.id,
Expand Down
Loading

0 comments on commit d4c5405

Please sign in to comment.