WIP: containers dashboard - loki logs
This commit is contained in:
parent
c38f94f4ce
commit
30510c6690
@ -1,11 +1,23 @@
|
||||
from grafanalib.core import (
|
||||
Dashboard, TimeSeries,
|
||||
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
|
||||
|
||||
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(
|
||||
title='Containers',
|
||||
@ -34,6 +46,12 @@ dashboard = Dashboard(
|
||||
refresh=REFRESH_ON_TIME_RANGE_CHANGE,
|
||||
|
||||
),
|
||||
Template(
|
||||
name='logs_query',
|
||||
label='Log Search',
|
||||
query='',
|
||||
type='textbox',
|
||||
),
|
||||
]),
|
||||
timezone='browser',
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user