Skip to content

Can I replicate nginx's "time_iso8601" variable in unit? #1118

Discussion options

You must be logged in to vote

This is as close as I can get with Unit 1.31.1

"format": "`{\"@timestamp\":\"${new Date().toISOString()}\",\"remote_addr\":\"${remoteAddr}\",\"request\":\"${uri}\",\"http_referer\":\"${headers['Referer'] === undefined ? '-' : headers['Referer']}\",\"http_user_agent\":\"${headers['User-Agent']}\"}`"

Note that request is just the URI and that status, bytes, request_time are missing.

$ curl -i localhost:9000
HTTP/1.1 204 No Content
Server: Unit/1.31.1
Date: Thu, 08 Feb 2024 15:11:33 GMT
Content-Length: 0

{"@timestamp":"2024-02-08T15:11:33.616Z","remote_addr":"127.0.0.1","request":"/","http_referer":"-","http_user_agent":"curl/8.4.0"}

As I mentioned, JavaScript doesn't currently allow you t…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bunny-therapist
Comment options

@lcrilly
Comment options

Answer selected by bunny-therapist
@bunny-therapist
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants