My input JSON Object

"annotations": {
      "kubernetes.io/psp": "100-rootuser-psp",


      "check-key" : "hello world"
    }

In rsyslog code, I am assigning to some var

$!var = <<input json>>>

I am able to access check-key via $!var!check-key. How do I access
kubernetes.io/psp ?
I tried,

$!var!kubernetes.io/psp
$!var!kubernetes.io\/psp
$!var!kubernetes.io\\/psp

All of them throw syntax errors.

To add more context, mmkubernetes
<https://www.rsyslog.com/doc/master/configuration/modules/mmkubernetes.html>
module exposes annotations as $!kubernetes!annotations .

If annotations don't contain any special characters, then I am able to
access the key as $!kubernetes!annotations!check-key

But I am not able to access the first annotation (kubernetes.io/psp) as it
contains "/" in it.

As a workaround, I have replaced "/" with "-" using replace() function and
converted back into json using parse_json() and then accessed
$!kubernetes!annotations!kubernetes.io-psp and its working fine. But I am
sure there must be a better solution than that.

How do I do that ?
-- 
Regards,
Rajesh KSV
_______________________________________________
rsyslog mailing list
https://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to