-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
631 loki output #661
base: master
Are you sure you want to change the base?
631 loki output #661
Conversation
…/file.d into 631-loki-output
} | ||
|
||
func (p *Plugin) send(ctx context.Context, data []byte) (int, error) { | ||
output := map[string]interface{}{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! Good job but it's better to split up messages and extract fields to labels.
Here is example:
There is sample of config for file.d:
pipelines:
loki:
settings:
capacity: 1000
input:
type: http
emulate_mode: "elasticsearch"
address: ":9200"
actions:
- type: parse_es
- type: json_decode
field: message
output:
type: loki
address: http://localhost:3100
# you can suggest your structure of config
timestamp_field: timestamp
message_field: message
# I don’t know the purpose of the stream yet
stream:
- label: test_label
value: test_value
File with input messages (data.json):
{"index": {"_index": "index-main","_type": "span"}}
{"timestamp":"2024-08-01T10:31:55.665748976Z","k8s_container":"container","message":"Started"}
{"index": {"_index": "index-main","_type": "span"}}
{"timestamp":"2024-08-01T10:35:55.665748976Z","k8s_container":"container","message":"Stopped"}
send to file.d
curl "127.0.0.1:9200/input" -v -H 'Content-Type: application/json' -d @data.json
And file.d sends to loki:
{
"streams": [
{
"stream": {
"test_label": "test_value"
},
"values": [
[ "17225143070000000", "Started", {"k8s_container": "container"} ],
[ "17225143080000000", "Stopped", {"k8s_container": "container"} ]
]
}
]
}
Feel free for ask any questions!
Hello, thanks for feedback, yesterday i found out that there is loki-go client by Grafana, i tried to create my wheel as Loki HTTP client, may be rewrite using this library? What do you think, rewrite using library or make a little bit refactoring |
I think it's better to not use libraries (to avoid using dependencies) and make some fixes. |
looks good to me. try searching by labels and others logql examples |
Here is example of logs from Promtail to Loki. We have fields app, container, node_name, pod and you can search by them. And our k8s input plugin adds those labels as well. |
Loki
Added loki output plugin
Fixes #631