WIP: containers dashboard - loki logs
This commit is contained in:
parent
581346f019
commit
d8bef9a23d
@ -1,11 +1,23 @@
|
|||||||
from grafanalib.core import (
|
from grafanalib.core import (
|
||||||
Dashboard, TimeSeries,
|
Dashboard, TimeSeries,
|
||||||
Target, GridPos,
|
Target, GridPos,
|
||||||
Templating, Template, REFRESH_ON_TIME_RANGE_CHANGE
|
Templating, Template, REFRESH_ON_TIME_RANGE_CHANGE, Logs
|
||||||
)
|
)
|
||||||
from grafanalib.formatunits import BYTES_IEC, SECONDS, BYTES_SEC_IEC
|
from grafanalib.formatunits import BYTES_IEC, SECONDS, BYTES_SEC_IEC
|
||||||
|
|
||||||
prom_datasource='prometheus'
|
prom_datasource='prometheus'
|
||||||
|
loki_datasource='loki'
|
||||||
|
|
||||||
|
# TODO: this is (clown emoji), normal Target gave me errors in grafana
|
||||||
|
class LokiTarget(object):
|
||||||
|
def to_json_data(self):
|
||||||
|
return {
|
||||||
|
'datasource': loki_datasource,
|
||||||
|
'expr': '{compose_project=~"$compose_project", container_name=~"$container_name"} |= `$logs_query`',
|
||||||
|
'legendFormat': '{{ container_name }}',
|
||||||
|
'refId': 'A',
|
||||||
|
'queryType': 'range',
|
||||||
|
}
|
||||||
|
|
||||||
dashboard = Dashboard(
|
dashboard = Dashboard(
|
||||||
title='Containers',
|
title='Containers',
|
||||||
@ -34,6 +46,12 @@ dashboard = Dashboard(
|
|||||||
refresh=REFRESH_ON_TIME_RANGE_CHANGE,
|
refresh=REFRESH_ON_TIME_RANGE_CHANGE,
|
||||||
|
|
||||||
),
|
),
|
||||||
|
Template(
|
||||||
|
name='logs_query',
|
||||||
|
label='Log Search',
|
||||||
|
query='',
|
||||||
|
type='textbox',
|
||||||
|
),
|
||||||
]),
|
]),
|
||||||
timezone='browser',
|
timezone='browser',
|
||||||
panels=[
|
panels=[
|
||||||
@ -91,5 +109,23 @@ dashboard = Dashboard(
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Logs(
|
||||||
|
title='',
|
||||||
|
gridPos=GridPos(h=8, w=12, x=12, y=8),
|
||||||
|
showLabels=True,
|
||||||
|
showCommonLabels=True,
|
||||||
|
wrapLogMessages=True,
|
||||||
|
prettifyLogMessage=True,
|
||||||
|
dedupStrategy='numbers',
|
||||||
|
targets=[
|
||||||
|
LokiTarget(),
|
||||||
|
# Target(
|
||||||
|
# datasource=loki_datasource,
|
||||||
|
# expr='{compose_project=~"$compose_project", container_name=~"$container_name"} |= `$logs_query`',
|
||||||
|
# legendFormat='{{ container_name }}',
|
||||||
|
# refId='A',
|
||||||
|
# ),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
).auto_panel_ids()
|
).auto_panel_ids()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user