Loki: Fix filtering with structured metadata (#73955)

* check languageProvider to work with non-indexed metadata

* change loki devenv to work with non-indexed metadata

* trigger ci

* add forced labels after parsers

* add comment

* Update public/app/plugins/datasource/loki/modifyQuery.ts

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
This commit is contained in:
Sven Grossmann
2023-08-31 15:24:03 +02:00
committed by GitHub
parent e3c0bc7f5c
commit 423a451858
7 changed files with 109 additions and 53 deletions

View File

@@ -47,12 +47,12 @@ async function sleep(duration) {
});
}
async function lokiSendLogLine(timestampNs, line, tags) {
async function lokiSendLogLine(timestampNs, line, tags, nonIndexed = {}) {
const data = {
streams: [
{
stream: tags,
values: [[timestampNs, line]],
values: [[timestampNs, line, nonIndexed]],
},
],
};
@@ -187,8 +187,8 @@ async function sendNewLogs() {
const nowMs = new Date().getTime();
const timestampNs = `${nowMs}${getRandomNanosecPart()}`;
const item = getRandomLogItem(globalCounter)
await lokiSendLogLine(timestampNs, JSON.stringify(item), {age:'new', place:'moon', ...sharedLabels});
await lokiSendLogLine(timestampNs, logFmtLine(item), {age:'new', place:'luna', ...sharedLabels});
await lokiSendLogLine(timestampNs, JSON.stringify(item), {age:'new', place:'moon', ...sharedLabels}, {nonIndexed: 'value'});
await lokiSendLogLine(timestampNs, logFmtLine(item), {age:'new', place:'luna', ...sharedLabels}, {nonIndexed: 'value'});
const sleepDuration = 200 + Math.random() * 800; // between 0.2 and 1 seconds
await sleep(sleepDuration);
}

View File

@@ -1,5 +1,5 @@
loki:
image: grafana/loki:latest
image: grafana/loki:main
command: -config.file=/etc/loki/loki-config.yaml
volumes:
- ./docker/blocks/loki/loki-config.yaml:/etc/loki/loki-config.yaml

View File

@@ -21,7 +21,7 @@ schema_config:
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v11
schema: v13
index:
prefix: index_
period: 24h