Hi all,
I don't know how to give a dynamic value to this attributes
field in google_pubsub
output plugin.
Currently this is what I do, which is not DRY
output {
if [name] == "userRegistered" {
google_pubsub {
project_id => "a"
topic => "ab"
json_key_file => "abc"
attributes => {
"eventName" => "userRegistered"
}
}
}
}
This one tho, won't work, even tho the conditional statement can read from the name
field
output {
if [name] == "userRegistered" {
google_pubsub {
project_id => "a"
topic => "ab"
json_key_file => "abc"
attributes => {
"eventNameA" => "%{[name]}"
"eventNameB" => "%{name}"
"eventNameC" => "[name]"
}
}
}
}
What am I missing here?
Badger
April 12, 2022, 2:44pm
2
The output does not sprintf the attributes, so you cannot use a sprintf reference.
So there's no way to make it dynamic?
Badger
April 13, 2022, 3:30am
4
With the existing plugin I do not think it can be done. You could change this line from
attributes.each { |k, v| builder.putAttributes(k, v) }
to
attributes.each { |k, v| builder.putAttributes(k, event.sprintf(v)) }
and rebuild the plugin from source. Or submit a PR that does that, or open an issue on github requesting that someone else do so
If doing either of the latter then you might want to consider whether anyone on the planet would consider it useful to sprintf both k and v!
attributes.each { |k, v| builder.putAttributes(event.sprintf(k), event.sprintf(v)) }
1 Like
system
(system)
Closed
May 11, 2022, 3:31am
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.