Skip to content

Commit

Permalink
LOGMLE - Add logs options (#42)
Browse files Browse the repository at this point in the history
* Add logs options

This PR allows one to change the options of the logs panel.  I would
like the change the sortOrder in one of the panels that we use, but I
added all available options according to the documentation.

- [see panel docs](https://grafana.com/docs/grafana/latest/developers/kinds/composable/logs/panelcfg/schema-reference/)

* Bump version and fix build instructions
  • Loading branch information
dhpollack authored Jan 19, 2024
1 parent d734e34 commit d836067
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ grafana-dashboard --grafana-url https://my-grafana-host.domain.com update my-exa
## Build and install from source

```
python3 -m pip install wheel
python3 setup.py bdist_wheel
python3 -m pip install --force-reinstall dist/grafyaml-1.0-py3-none-any.whl
```
Expand Down
18 changes: 17 additions & 1 deletion grafana_dashboards/schema/panel/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,23 @@ def get_schema(self):
}

null_point_modes = v.Any("connected", "null", "null as zero")
value_types = v.Any("individual", "cumulative")

options = {
v.Optional("dedupStrategy", default="none"): v.All(
str, "none", "exact", "numbers", "signature"
),
v.Optional("enableLogDetails", default=True): v.All(bool),
v.Optional("prettifyLogMessage", default=False): v.All(bool),
v.Optional("showCommonLabels", default=False): v.All(bool),
v.Optional("showLabels", default=False): v.All(bool),
v.Optional("showTime", default=False): v.All(bool),
v.Optional("sortOrder", default="Descending"): v.All(
str, "Ascending", "Descending"
),
v.Optional("wrapLogMessage", default=False): v.All(bool),
}

value_types = v.Any("individual", "cumulative")
tooltip = {
v.Required("query_as_alias", default=True): v.All(bool),
v.Required("shared", default=True): v.All(bool),
Expand Down Expand Up @@ -102,6 +117,7 @@ def get_schema(self):
v.Required("linewidth", default=2): v.All(int),
v.Optional("minSpan"): v.All(int, v.Range(min=0, max=12)),
v.Optional("nullPointMode"): v.All(null_point_modes),
v.Optional("options", default={}): v.All(options),
v.Required("percentage", default=False): v.All(bool),
v.Required("pointradius", default=5): v.All(int),
v.Required("points", default=False): v.All(bool),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="grafyaml",
version="1.4.1",
version="1.4.2",
url="https://github.com/deliveryhero/grafyaml",
license="Apache v2.0",
description="A nice and easy way to template Grafana dashboards in YAML",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import os

import mock
from unittest import mock

from grafana_dashboards import builder
from tests.base import TestCase
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ deps =
coverage>=3.6
python-subunit>=0.0.18
requests-mock>=0.6.0
mock>=1.2
oslotest>=1.2.0
testrepository>=0.0.18
testscenarios>=0.4
Expand Down

0 comments on commit d836067

Please sign in to comment.