From 67d93ae8ae6cd6849d33f187959f39ed283ec6e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 14:38:36 +0100 Subject: [PATCH 01/11] Bump actions/setup-python from 5.0.0 to 5.1.0 (#654) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5.0.0...v5.1.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/publish-to-pypi.yml | 2 +- .github/workflows/run-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 8835dc3b..3dd67c18 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5.1.0 with: python-version: '3.10' - name: Build a binary wheel and a source tarball diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e0491069..45429690 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.0.0 + uses: actions/setup-python@v5.1.0 with: python-version: ${{ matrix.python }} - name: Run tests From d6b8866b992081cc6941033e60425fb2dc3da5b9 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Mon, 1 Apr 2024 15:40:14 +0200 Subject: [PATCH 02/11] chore: Update project metadata to reflect minimum Python version 3.8 (#652) The package is no longer compatible with Python 3.7 after starting to use `typing.Literal` recently. --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index bde138ba..613b21cd 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,6 @@ def local_file(name): 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', From 5496e43abb9ca2a0eea72f902def4289468f6813 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:11:54 +0100 Subject: [PATCH 03/11] Bump sphinx from 7.2.6 to 7.4.3 (#667) Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 7.2.6 to 7.4.3. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v7.2.6...v7.4.3) --- updated-dependencies: - dependency-name: sphinx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 7f71fb4e..f174d639 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ -sphinx == 7.2.6 +sphinx == 7.4.3 sphinx_rtd_theme == 2.0.0 From 7cb7c07cabdae7802b0944e55efd767c16f43118 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:12:53 +0100 Subject: [PATCH 04/11] Bump actions/setup-python from 5.1.0 to 5.1.1 (#666) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.0 to 5.1.1. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v5.1.0...v5.1.1) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/publish-to-pypi.yml | 2 +- .github/workflows/run-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 3dd67c18..b6844168 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.1.1 with: python-version: '3.10' - name: Build a binary wheel and a source tarball diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 45429690..e1bae165 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v5.1.0 + uses: actions/setup-python@v5.1.1 with: python-version: ${{ matrix.python }} - name: Run tests From 6b4ad2a975103f9e19452daeebb56b7a2cc53749 Mon Sep 17 00:00:00 2001 From: Anson Chu Date: Tue, 16 Jul 2024 05:16:40 -0700 Subject: [PATCH 05/11] add mappings to field config for Table (#664) * add mappings to field config for Table * add entry in changelog --------- Co-authored-by: anson --- CHANGELOG.rst | 2 ++ grafanalib/core.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cc53f617..e7e7b46e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,8 @@ Changelog ========= x.x.x ? +* Fix mappings for Table + ================== * Added ... diff --git a/grafanalib/core.py b/grafanalib/core.py index 74837b5c..a6a1ae9d 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -3312,7 +3312,8 @@ def to_json_data(self): 'displayMode': self.displayMode, 'filterable': self.filterable, }, - 'unit': self.unit + 'unit': self.unit, + 'mappings': self.mappings }, 'overrides': self.overrides }, From 05d801c0d3163027f31b8e407ae43ba2aaa5a263 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:20:54 +0100 Subject: [PATCH 06/11] Bump lycheeverse/lychee-action from 1.9.3 to 1.10.0 (#658) Bumps [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) from 1.9.3 to 1.10.0. - [Release notes](https://github.com/lycheeverse/lychee-action/releases) - [Commits](https://github.com/lycheeverse/lychee-action/compare/v1.9.3...v1.10.0) --- updated-dependencies: - dependency-name: lycheeverse/lychee-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/check-sphinx-and-links.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-sphinx-and-links.yml b/.github/workflows/check-sphinx-and-links.yml index f15d015d..f04da174 100644 --- a/.github/workflows/check-sphinx-and-links.yml +++ b/.github/workflows/check-sphinx-and-links.yml @@ -23,7 +23,7 @@ jobs: - name: Link Checker id: lc - uses: lycheeverse/lychee-action@v1.9.3 + uses: lycheeverse/lychee-action@v1.10.0 with: args: --verbose **/*.html - name: Fail if there were link errors From d4c10e9b5feeacd520b84010cdf8de0323290247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Sj=C3=B6din?= <86059470+MattiasMTS@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:26:34 +0200 Subject: [PATCH 07/11] feat: add account to CloudwatchMetricsTarget (#661) * feat: add account to CloudwatchMetricsTarget * docs: update changelog * Update grafanalib/cloudwatch.py --------- Co-authored-by: JamesGibo <22477854+JamesGibo@users.noreply.github.com> --- CHANGELOG.rst | 10 +++++----- grafanalib/cloudwatch.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e7e7b46e..34c3ac04 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,15 +2,15 @@ Changelog ========= -x.x.x ? -* Fix mappings for Table -================== +x.x.x ? +======= -* Added ... +* Fix mappings for Table +* Added support for AWS Cross-Account in CloudwatchMetricsTarget 0.7.1 2024-01-12 -================== +================ * Extended DashboardLink to support links to dashboards and urls, as per the docs_ diff --git a/grafanalib/cloudwatch.py b/grafanalib/cloudwatch.py index a9a22248..f72d891b 100644 --- a/grafanalib/cloudwatch.py +++ b/grafanalib/cloudwatch.py @@ -1,8 +1,8 @@ """Helpers to create Cloudwatch-specific Grafana queries.""" import attr - from attr.validators import instance_of + from grafanalib.core import Target @@ -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 @@ -32,11 +34,14 @@ class CloudwatchMetricsTarget(Target): :param hide: controls if given metric is displayed on visualization :param datasource: Grafana datasource name """ + 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="") @@ -48,13 +53,14 @@ class CloudwatchMetricsTarget(Target): datasource = attr.ib(default=None) 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, @@ -88,6 +94,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)) @@ -99,7 +106,6 @@ class CloudwatchLogsInsightsTarget(Target): datasource = attr.ib(default=None) def to_json_data(self): - return { "expression": self.expression, "id": self.id, From 52c69c8920b0fee6925e43a6b5388cef96eb7db3 Mon Sep 17 00:00:00 2001 From: bytemonk Date: Tue, 16 Jul 2024 17:59:29 +0530 Subject: [PATCH 08/11] bytemonk: Added tooltip sort to PieChartv2 panel (#659) * added tooltipSort to Piechartv2 Panel * added tooltipSort to PieChartv2 Panel --------- Co-authored-by: JamesGibo <22477854+JamesGibo@users.noreply.github.com> --- CHANGELOG.rst | 2 ++ grafanalib/core.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 34c3ac04..bbdea066 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,9 +6,11 @@ Changelog x.x.x ? ======= +* Added ``tooltipSort`` parameter to PieChartv2 panel * Fix mappings for Table * Added support for AWS Cross-Account in CloudwatchMetricsTarget + 0.7.1 2024-01-12 ================ diff --git a/grafanalib/core.py b/grafanalib/core.py index a6a1ae9d..f46749f2 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -3834,6 +3834,8 @@ class PieChartv2(Panel): :param reduceOptionsValues: Calculate a single value per column or series or show each row :param tooltipMode: Tooltip mode single (Default), multi, none + :param tooltipSort: To sort the tooltips + none (Default), asc, desc :param unit: units """ @@ -3849,6 +3851,7 @@ class PieChartv2(Panel): reduceOptionsFields = attr.ib(default='', validator=instance_of(str)) reduceOptionsValues = attr.ib(default=False, validator=instance_of(bool)) tooltipMode = attr.ib(default='single', validator=instance_of(str)) + tooltipSort = attr.ib(default='none', validator=instance_of(str)) unit = attr.ib(default='', validator=instance_of(str)) def to_json_data(self): @@ -3873,7 +3876,8 @@ def to_json_data(self): }, 'pieType': self.pieType, 'tooltip': { - 'mode': self.tooltipMode + 'mode': self.tooltipMode, + 'sort': self.tooltipSort }, 'legend': { 'displayMode': self.legendDisplayMode, From eedff24f794f087844a73a4f78497c890519a960 Mon Sep 17 00:00:00 2001 From: Andreas Sommer Date: Tue, 16 Jul 2024 14:33:02 +0200 Subject: [PATCH 09/11] Add Loki target (#657) Co-authored-by: JamesGibo <22477854+JamesGibo@users.noreply.github.com> --- CHANGELOG.rst | 2 +- grafanalib/core.py | 23 +++++++++++++++++++++++ grafanalib/tests/test_core.py | 26 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bbdea066..2561aa57 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,7 +9,7 @@ x.x.x ? * 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 ================ diff --git a/grafanalib/core.py b/grafanalib/core.py index f46749f2..4515965d 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -606,6 +606,29 @@ def to_json_data(self): } +# Currently not deriving from `Target` because Grafana errors if fields like `query` are added to Loki targets +@attr.s +class LokiTarget(object): + """ + Target for Loki LogQL queries + """ + + datasource = attr.ib(default='', validator=instance_of(str)) + expr = attr.ib(default='', validator=instance_of(str)) + hide = attr.ib(default=False, validator=instance_of(bool)) + + def to_json_data(self): + return { + 'datasource': { + 'type': 'loki', + 'uid': self.datasource, + }, + 'expr': self.expr, + 'hide': self.hide, + 'queryType': 'range', + } + + @attr.s class SqlTarget(Target): """ diff --git a/grafanalib/tests/test_core.py b/grafanalib/tests/test_core.py index 62cf6ff4..4f93d2ba 100644 --- a/grafanalib/tests/test_core.py +++ b/grafanalib/tests/test_core.py @@ -1152,6 +1152,32 @@ def test_target_invalid(): ) +def test_loki_target(): + t = G.Dashboard( + title='unittest', + uid='unit-test-uid', + timezone='browser', + panels=[ + G.TimeSeries( + title='Some logs', + targets=[ + G.LokiTarget( + datasource='my-logs', + expr='{pod="unittest"} |= "hello"', + ), + ], + gridPos=G.GridPos(h=10, w=24, x=0, y=0), + ), + ], + ).auto_panel_ids() + + dashboard_json = t.to_json_data() + target_json = dashboard_json['panels'][0].targets[0].to_json_data() + # Grafana wants type/uid fields for Loki targets (as of 2024-04) + assert target_json['datasource']['type'] == 'loki' + assert target_json['datasource']['uid'] == 'my-logs' + + def test_sql_target(): t = G.Table( dataSource="some data source", From 16e2bcff21bb353a5515ec897fc9be8f7d2b6a7f Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Tue, 16 Jul 2024 14:46:40 +0200 Subject: [PATCH 10/11] fix: correct spelling errors for temperature units (#665) * fix: correct spelling errors for temperature units * fix: add breaking change to changelog --- CHANGELOG.rst | 1 + grafanalib/formatunits.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2561aa57..04c6510c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Changelog x.x.x ? ======= +* **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 diff --git a/grafanalib/formatunits.py b/grafanalib/formatunits.py index 54112427..3fbd76ec 100644 --- a/grafanalib/formatunits.py +++ b/grafanalib/formatunits.py @@ -238,9 +238,9 @@ RADS_PER_SEC = 'rotrads' # rad/s DEGREES_PER_SECOND = 'rotdegs' # °/s # Temperature -CELSUIS = 'celsius' # °C -FARENHEIT = 'fahrenheit' # °F -KELVIN = 'kelvin' # K +CELSIUS = 'celsius' # °C +FAHRENHEIT = 'fahrenheit' # °F +KELVIN = 'kelvin' # K # Time HERTZ = 'hertz' # Hz NANO_SECONDS = 'ns' # ns From dc2df719958680e5be171972c1f92076809d4691 Mon Sep 17 00:00:00 2001 From: Jan Seidl Date: Tue, 16 Jul 2024 14:47:57 +0200 Subject: [PATCH 11/11] Neutral option for GaugePanel (#649) * Some targets (Influx for example) use alias insted of legendFormat (which is Prometheus 'alias'). This commit setup both of them by legendFormat. * Added `neutral` option for `GaugePanel` (supported by Grafana 9.3.0 - https://github.com/grafana/grafana/discussions/38273) --------- Co-authored-by: JamesGibo <22477854+JamesGibo@users.noreply.github.com> --- CHANGELOG.rst | 2 ++ grafanalib/core.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 04c6510c..efa486c8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,8 @@ Changelog x.x.x ? ======= +* 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 diff --git a/grafanalib/core.py b/grafanalib/core.py index 4515965d..79849fea 100644 --- a/grafanalib/core.py +++ b/grafanalib/core.py @@ -573,6 +573,7 @@ class Target(object): Metric to show. :param target: Graphite way to select data + :param legendFormat: Target alias. Prometheus use legendFormat, other like Influx use alias. This set legendFormat as well as alias. """ expr = attr.ib(default="") @@ -598,6 +599,7 @@ def to_json_data(self): 'interval': self.interval, 'intervalFactor': self.intervalFactor, 'legendFormat': self.legendFormat, + 'alias': self.legendFormat, 'metric': self.metric, 'refId': self.refId, 'step': self.step, @@ -3463,6 +3465,7 @@ class GaugePanel(Panel): :param thresholdMarkers: option to show marker of level on gauge :param thresholds: single stat thresholds :param valueMaps: the list of value to text mappings + :param neutral: neutral point of gauge, leave empty to use Min as neutral point """ allValues = attr.ib(default=False, validator=instance_of(bool)) @@ -3487,6 +3490,7 @@ class GaugePanel(Panel): validator=instance_of(list), ) valueMaps = attr.ib(default=attr.Factory(list)) + neutral = attr.ib(default=None) def to_json_data(self): return self.panel_json( @@ -3504,6 +3508,9 @@ def to_json_data(self): 'mappings': self.valueMaps, 'override': {}, 'values': self.allValues, + 'custom': { + 'neutral': self.neutral, + }, }, 'showThresholdLabels': self.thresholdLabels, 'showThresholdMarkers': self.thresholdMarkers,