Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating JSON content in irule

Guillaume_Rouss
Nimbostratus
Nimbostratus

Hello.

I'm using an irule to send traffic logs to a remote syslog server, using JSON format. Currently I'm creating JSON content manually, using format function, ie:

set message [format {{ "key1":"%s", "key2":"%s", ... }} $value1 $value2 ... ]
HSL::send $hsl $message

However, this is a bit painful, especially as the number of key/value pairs rise, and doesn't handle internal escaping of characters inside values. Is there a better way to create JSON content in irule ?

2 REPLIES 2

Hello Guillaume.

 

You could use a request-logging and set a JSON format in the request-logging template.

https://support.f5.com/csp/article/K00847516

 

Regards,

Dario.

Regards,
Dario.

Guillaume_Rouss
Nimbostratus
Nimbostratus

Hello Dario, thanks for the suggestion. Unfortunately, this will only work for HTTP traffic, whereas I have other kind of traffic to report, such as SMTP, IMAP, POP, etc...