Skip to content

Commit 92a771c

Browse files
authored
ROB-708: use loki as fully fledged log provider (#1746)
* feat: update loki and tempo docs * feat: add docs for datetime toolset * feat: add docs for datetime toolset * doc: update grafana loki config
1 parent 132d02c commit 92a771c

6 files changed

Lines changed: 178 additions & 70 deletions

File tree

docs/configuration/holmesgpt/builtin_toolsets.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ by the user by providing credentials or API keys to external systems.
6262
:link: toolsets/docker
6363
:link-type: doc
6464

65-
.. grid-item-card:: :octicon:`cpu;1em;` Grafana
65+
.. grid-item-card:: :octicon:`cpu;1em;` Grafana Loki
6666
:class-card: sd-bg-light sd-bg-text-light
67-
:link: toolsets/grafana
67+
:link: toolsets/grafanaloki
68+
:link-type: doc
69+
70+
.. grid-item-card:: :octicon:`cpu;1em;` Grafana Tempo
71+
:class-card: sd-bg-light sd-bg-text-light
72+
:link: toolsets/grafanatempo
6873
:link-type: doc
6974

7075
.. grid-item-card:: :octicon:`cpu;1em;` Helm

docs/configuration/holmesgpt/toolsets/datetime.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ Datetime :checkmark:`_`
33
.. include:: ./_toolset_enabled_by_default.inc.rst
44

55
By enabling this toolset, HolmesGPT will be able to get the current UTC date and time.
6-
This feature works well with other toolsets. For example, the :doc:`prometheus <prometheus>`
7-
toolset needs ``start`` and ``end`` time parameters to properly create and execute
8-
PromQL queries.
6+
This feature should be kept enabled as it can be necessary for other toolsets that rely
7+
on dates and time.
8+
9+
The following built-in toolsets depend on ``datetime``:
10+
11+
* :ref:`grafana/loki <toolset_grafana_loki>`
12+
* :ref:`prometheus/metrics <toolset_prometheus>`
913

1014
Configuration
1115
-------------
Lines changed: 104 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
.. _toolset_grafana_loki:
2+
13
Loki (Grafana)
24
===============
35

4-
By enabling this toolset, HolmesGPT will be able to query logs from `Loki <https://grafana.com/oss/loki/>`_
6+
By enabling this toolset, HolmesGPT will fetch node and pods logs from `Loki <https://grafana.com/oss/loki/>`_
57
by proxying through a `Grafana <https://grafana.com/oss/grafana/>`_ instance.
68

7-
After this toolset is enabled, you can ask Holmes questions like: *Look at my cluster with kubectl, pick an arbitrary node, then fetch logs from loki for that node. Summarize all problems you find.*
9+
You **should** enable this toolset to replace the default :ref:`kubernetes/logs <toolset_kubernetes_logs>`
10+
toolset if all your kubernetes/pod logs are consolidated inside Loki. It will make it easier for HolmesGPT
11+
to fetch incident logs, including the ability to precisely consult past logs.
812

913
Prerequisites
1014
^^^^^^^^^^^^^
15+
1116
A `Grafana service account token <https://grafana.com/docs/grafana/latest/administration/service-accounts/>`_
1217
with the following permissions:
1318

@@ -19,48 +24,80 @@ Check out this `video <https://www.loom.com/share/f969ab3af509444693802254ab0407
1924
Getting Grafana URL
2025
-----------------------
2126

22-
You can find the Grafana URL required for Loki and Tempo in your Grafana cloud account settings.
27+
You can find the Grafana URL required for Loki in your Grafana cloud account settings.
2328

2429
.. image:: /images/grafana-url-for-holmes.png
2530
:width: 600
2631
:align: center
2732

33+
34+
Obtaining the datasource UID
35+
-----------------------
36+
37+
You may have multiple Loki data sources setup in Grafana. HolmesGPT uses a single Loki datasource to
38+
fetch the logs and it needs to know the UID of this datasource.
39+
40+
A simple way to get the datasource UID is to access the Grafana API by running the following request:
41+
42+
.. code-block:: bash
43+
44+
# port forward if you are using Robusta's grafana from your kubernetes cluster
45+
kubectl port-forward svc/robusta-grafana 3000:80
46+
47+
# List the loki data sources
48+
curl -s -u <username>:<password> http://localhost:3000/api/datasources | jq '.[] | select(.type == "loki")'
49+
{
50+
"id": 2,
51+
"uid": "klja8hsa-8a9c-4b35-1230-7baab22b02ee",
52+
"orgId": 1,
53+
"name": "Loki-kubernetes",
54+
"type": "loki",
55+
"typeName": "Loki",
56+
"typeLogoUrl": "/public/app/plugins/datasource/loki/img/loki_icon.svg",
57+
"access": "proxy",
58+
"url": "http://loki.loki:3100",
59+
"user": "",
60+
"database": "",
61+
"basicAuth": false,
62+
"isDefault": false,
63+
"jsonData": {
64+
"httpHeaderName1": "admin",
65+
"httpHeaderName2": "X-Scope-OrgID",
66+
"tlsSkipVerify": true
67+
},
68+
"readOnly": false
69+
}
70+
# In this case, there is a single Loki datasourceUID
71+
# with UID "klja8hsa-8a9c-4b35-1230-7baab22b02ee"
72+
73+
2874
Configuration
2975
^^^^^^^^^^^^^
3076

31-
.. md-tab-set::
3277

33-
.. md-tab-item:: Robusta Helm Chart
78+
.. md-tab-set::
3479

35-
Add the following to **Robusta's Helm values:**
80+
.. md-tab-item:: Robusta Helm Chat
3681

3782
.. code-block:: yaml
3883
39-
holmes:
40-
toolsets:
41-
grafana/loki:
42-
enabled: true
43-
config:
44-
api_key: <your grafana service account token>
45-
url: <your grafana url> # e.g. https://acme-corp.grafana.net
46-
47-
.. include:: ./_toolset_configuration.inc.rst
84+
holmes:
85+
toolsets:
86+
grafana/loki:
87+
enabled: true
88+
config:
89+
api_key: <your grafana API key>
90+
url: https://xxxxxxx.grafana.net # Your Grafana cloud account URL
91+
grafana_datasource_uid: <the UID of the loki data source in Grafana>
92+
labels:
93+
pod: "pod"
94+
namespace: "namespace"
4895
49-
You can optionally tweak the search terms used by the toolset. This is only needed if your Loki logs settings for pod,
50-
namespace and node differ from the defaults listed below. To do so, add these search keys to the configuration:
96+
kubernetes/logs:
97+
enabled: false # Disable HolmesGPT's default logging mechanism
5198
52-
.. code-block:: yaml
5399
54-
holmes:
55-
toolsets:
56-
grafana/loki:
57-
enabled: true
58-
config:
59-
api_key: <your grafana service account token>
60-
url: <your grafana url> # e.g. https://acme-corp.grafana.net
61-
pod_name_search_key: "pod"
62-
namespace_search_key: "namespace"
63-
node_name_search_key: "node"
100+
.. include:: ./_toolset_configuration.inc.rst
64101

65102
.. md-tab-item:: Holmes CLI
66103

@@ -72,29 +109,45 @@ Configuration
72109
grafana/loki:
73110
enabled: true
74111
config:
75-
api_key: <your grafana service account token>
76-
url: <your grafana url> # e.g. https://acme-corp.grafana.net
77-
78-
You can optionally tweak the search terms used by the toolset. This is only needed if your Loki logs settings for pod,
79-
namespace and node differ from the defaults listed below. To do so, add these search keys to the configuration:
112+
api_key: <your grafana API key>
113+
url: https://xxxxxxx.grafana.net # Your Grafana cloud account URL
114+
grafana_datasource_uid: <the UID of the loki data source in Grafana>
115+
labels:
116+
pod: "pod"
117+
namespace: "namespace"
80118
81-
.. code-block:: yaml
119+
kubernetes/logs:
120+
enabled: false # Disable HolmesGPT's default logging mechanism
82121
83-
toolsets:
84-
grafana/loki:
85-
enabled: true
86-
config:
87-
api_key: <your grafana service account token>
88-
url: <your grafana url> # e.g. https://acme-corp.grafana.net
89-
pod_name_search_key: "pod"
90-
namespace_search_key: "namespace"
91-
node_name_search_key: "node"
92122
93-
To test, run:
123+
**Search labels**
124+
125+
You can tweak the labels used by the toolset to identify kubernetes resources. This is only needed if your
126+
Loki logs settings for ``pod``, and ``namespace`` differ from the defaults in the example above.
127+
128+
Use the following commands to list Loki's labels and determine which ones to use:
129+
130+
.. code-block:: bash
131+
132+
# Make Loki accessible locally
133+
kubectl port-forward svc/loki 3100:3100
134+
135+
# List all labels. You may have to add the -H 'X-Scope-OrgID:<org id>' option with a valid org id
136+
curl http://localhost:3100/loki/api/v1/labels
137+
138+
139+
140+
If Loki is your primary datasource for logs, it is **advised** to disable the default HolmesGPT logging
141+
tool by disabling the ``kubernetes/logs`` toolset. Without this. HolmesGPT may still use kubectl to
142+
fetch logs instead of Loki.
143+
144+
.. code-block:: yaml
145+
146+
holmes:
147+
toolsets:
148+
kubernetes/logs:
149+
enabled: false
94150
95-
.. code-block:: yaml
96-
97-
holmes ask "Which applications have an issue and check the logs on loki for the reasons"
98151
99152
Capabilities
100153
^^^^^^^^^^^^
@@ -107,14 +160,7 @@ Capabilities
107160

108161
* - Tool Name
109162
- Description
110-
* - list_loki_datasources
111-
- Fetches the Loki data sources in Grafana
112-
* - fetch_loki_logs_by_node
113-
- Fetches the Loki logs for a given node
114-
* - fetch_loki_logs_by_label
115-
- Fetches the Loki logs for a label and value from a Tempo trace
116-
* - fetch_loki_logs_by_pod
117-
- Fetches the Loki logs for a given pod
118-
119-
120-
163+
* - fetch_loki_logs_for_resource
164+
- Fetches the Loki logs for a given kubernetes resource
165+
* - fetch_loki_logs
166+
- Fetches Loki logs from any query

docs/configuration/holmesgpt/toolsets/grafanatempo.rst

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,53 @@ Check out this `video <https://www.loom.com/share/f969ab3af509444693802254ab0407
1818
Getting Grafana URL
1919
-----------------------
2020

21-
You can find the Grafana URL required for Loki and Tempo in your Grafana cloud account settings.
21+
You can find the Grafana URL required for Tempo in your Grafana cloud account settings.
2222

2323
.. image:: /images/grafana-url-for-holmes.png
2424
:width: 600
2525
:align: center
2626

27+
28+
Obtaining the datasource UID
29+
-----------------------
30+
31+
You may have multiple Tempo data sources setup in Grafana. HolmesGPT uses a single Tempo datasource to
32+
fetch the traces and it needs to know the UID of this datasource.
33+
34+
A simple way to get the datasource UID is to access the Grafana API by running the following request:
35+
36+
.. code-block:: bash
37+
38+
# port forward if you are using Robusta's grafana from your kubernetes cluster
39+
kubectl port-forward svc/robusta-grafana 3000:80
40+
41+
# List the loki data sources
42+
curl -s -u <username>:<password> http://localhost:3000/api/datasources | jq '.[] | select(.type == "loki")'
43+
{
44+
"id": 2,
45+
"uid": "klja8hsa-8a9c-4b35-1230-7baab22b02ee",
46+
"orgId": 1,
47+
"name": "Tempo-kubernetes",
48+
"type": "tempo",
49+
"typeName": "Tempo",
50+
"typeLogoUrl": "/public/app/plugins/datasource/tempo/img/tempo_icon.svg",
51+
"access": "proxy",
52+
"url": "http://tempo.tempo:3100",
53+
"user": "",
54+
"database": "",
55+
"basicAuth": false,
56+
"isDefault": false,
57+
"jsonData": {
58+
"httpHeaderName1": "admin",
59+
"httpHeaderName2": "X-Scope-OrgID",
60+
"tlsSkipVerify": true
61+
},
62+
"readOnly": false
63+
}
64+
# In this case, there is a single Tempo datasourceUID
65+
# with UID "klja8hsa-8a9c-4b35-1230-7baab22b02ee"
66+
67+
2768
Configuration
2869
^^^^^^^^^^^^^
2970

@@ -40,6 +81,7 @@ Configuration
4081
config:
4182
api_key: <your grafana API key>
4283
url: https://grafana-url
84+
grafana_datasource_uid: <the UID of the tempo data source in Grafana>
4385
4486
.. include:: ./_toolset_configuration.inc.rst
4587

@@ -54,12 +96,13 @@ Configuration
5496
enabled: true
5597
config:
5698
api_key: <your grafana service account token>
57-
url: <your grafana url> # e.g. https://acme-corp.grafana.net
99+
url: <your grafana url> # e.g. https://acme-corp.grafana.net
100+
grafana_datasource_uid: <the UID of the tempo data source in Grafana>
58101
59-
To test, run:
102+
To test, run:
60103

61104
.. code-block:: yaml
62-
105+
63106
holmes ask "The payments DB is very slow, check tempo for any trace data"
64107
65108
Capabilities
@@ -78,4 +121,3 @@ Capabilities
78121
- Lists Tempo traces ids that exceed a specified minimum duration in a given time range
79122
* - fetch_tempo_trace_by_id
80123
- Retrieves detailed information about a Tempo trace using its trace ID. Use this to investigate a trace.
81-

docs/configuration/holmesgpt/toolsets/kubernetes.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ Capabilities
5252
* - kubernetes_jq_query
5353
- Query Kubernetes resources using jq filters
5454

55+
.. _toolset_kubernetes_logs:
5556

5657
Logs :checkmark:`_`
5758
-------------------
5859

59-
.. include:: ./_toolset_enabled_by_default.inc.rst
60+
:checkmark:`_`: **This toolset is enabled by default**. You do not need to configure
61+
it.
62+
63+
By enabling this toolset, HolmesGPT will be able to read kubernetes pod logs.
64+
65+
You may disable this toolset if you provide Holmes with an alternative toolset to
66+
fetch logs from your kubernetes cluster and applications. The available built-in
67+
toolsets that provide logging are:
68+
69+
* :ref:`grafana/loki <toolset_grafana_loki>`: Access Loki logs by proxying through a Grafana instance
6070

61-
Read kubernetes pod logs.
6271

6372
Configuration
6473
^^^^^^^^^^^^^

docs/configuration/holmesgpt/toolsets/prometheus.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _toolset_prometheus:
2+
13
Prometheus
24
==========
35

0 commit comments

Comments
 (0)