Closed jinnyu closed 2 years ago
log_format
config
Can you give the full command to configure log_format
, the format you gave looks strange and I don't remember keywords like streams
.
curl --location --request PUT 'http://a6:9080/apisix/admin/plugin_metadata/http-logger' \
--header 'X-API-KEY: 123456789' \
--header 'Content-Type: application/json' \
--data-raw '{
"log_format": {
"streams": [
{
"stream": {
"serviceName": "$service_name",
"routeName": "$route_name",
"host": "$host",
"balancer": "$balancer_ip:$balancer_port"
},
"values": [
[
"$msec",
"{\"ts\":\"$msec\",\"status\":\"$status\",\"request\":{\"ua\":\"$http_user_agent\",\"body-size\":\"$body_bytes_sent\",\"request\":\"$request\"},\"upstream\":{\"addr\":\"$upstream_addr\",\"host\":\"$upstream_host\",\"uri\":\"$upstream_uri\",\"status\":\"$upstream_status\",\"responseTime\":\"$upstream_response_time\"}}"
]
]
}
]
}
}'
I want to send content in json format Should I escape all characters?
http-logger
seems that cannot handle JSON content of nested types.
But without config log_format
, why plugin can process nested content correctly?
The log_foramt
above is Loki
's format,
I want to config log_format
to Loki
's format, so that plugin can be send log to Loki
directly without more process.
The
log_foramt
above isLoki
's format
I think that's the wrong format, you can take a look at: https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/http-logger.md
@jinnyu FYI:
Log format declared as key value pairs in JSON format. Values only support strings. APISIX or Nginx variables can be used > by prefixing the string with $.
Thank you!~ I missed that note.
Are there plans to support nested formats?
@tokers Hi, I also want to use http-logger to push log data to loki. Any plans with supporting nested json format?
Current Behavior
http-logger
lua report error.Expected Behavior
Send the request to the configured service correctly
Error Logs
Steps to Reproduce
http-logger
globallylog_format
configif enable plugin only, no
log_format
config, plugin can work correctly with default format, but whenlog_format
is configured, an error will be reportedEnvironment
apisix version
): 2.13.0 and 2.14.1uname -a
): offical docker imageopenresty -V
ornginx -V
):curl http://127.0.0.1:9090/v1/server_info
): 3.14.8luarocks --version
):