How to append a string to a value?

Hi,

I would like to append the letter C to this key:
"module-temp": 32.37 so that it looks like "module-temp": 32.37 C

Tried this but didn't work:

 if ("*" in [module-temp]) {
        mutate {
            replace => {"module-temp" => "%{module-temp} C"}
        }
    }

What are you trying to test using that conditional? The mutate+replace looks good.

I was just trying an alternate to:

 if [module-temp] {
        mutate {
            replace => {"module-temp" => "%{module-temp} C"}
        }
    }

What you have here works if you use your second conditional statement method.

Conf

input {
  generator {
    message => '{"module-temp": 32.37} '
    count => 1
    codec => "json"
  }
}
filter {
  if [module-temp] {
    mutate {
      replace => {"module-temp" => "%{module-temp} C"}
    }
  }  
}
output {
  stdout { }
}

Output

"module-temp": "32.37 C"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.