jinnyu opened a new issue, #7324:
URL: https://github.com/apache/apisix/issues/7324
### Description
Hi, I'm using `http-logger` plugin to log request to Loki.
I configed `log_format` to this
```
{
"log_format": {
"streams": [
{
"stream": {
"serviceName": "$service_name",
"routeName": "$route_name",
"host": "$host",
"balancer": "$balancer_ip:$balancer_port"
},
"values": [
[
"$unix_ts",
"{\"ts\":\"$unix_ts\",\"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\"}}"
]
]
}
]
}
}
```
(`$unix_ts` is defined by `map` config in apisix main config)
```
apisix:
nginx_config:
http_configuration_snippet: |
map $msec $unix_ts {
~(.*)\.(.*) $1$2;
}
```
All config done, send request to apisix,
Apisix report an error
```
2022/06/24 14:14:27 [error] 49#49: *935 failed to run log_by_lua*:
/usr/local/apisix/apisix/utils/log-util.lua:46: attempt to call method 'byte'
(a nil value)
stack traceback:
/usr/local/apisix/apisix/utils/log-util.lua:46: in function
'create_obj_fun'
/usr/local/apisix/apisix/core/lrucache.lua:95: in function
'lru_log_format'
/usr/local/apisix/apisix/utils/log-util.lua:57: in function
'get_custom_format_log'
/usr/local/apisix/apisix/plugins/http-logger.lua:167: in function
'phase_func'
/usr/local/apisix/apisix/plugin.lua:771: in function 'run_plugin'
/usr/local/apisix/apisix/plugin.lua:804: in function
'run_global_rules'
/usr/local/apisix/apisix/init.lua:311: in function 'common_phase'
/usr/local/apisix/apisix/init.lua:710: in function 'http_log_phase'
log_by_lua(nginx.conf:309):2: in main chunk while logging request,
client: 172.17.132.35, server: _, request: "GET /rest/2.0/ocr/v1/idcard
HTTP/1.1", upstream:
"[https://somehost.com:443/somepath](https://somehost.com/somepath)", host:
"10.26.20.220:4006"
```
So, are variables defined by the map method not supported in the plugin?
And how to solve this?
### Environment
- APISIX version (run `apisix version`): 2.14.1-centos (offical docker image)
- Operating system (run `uname -a`): offical docker image
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): offical
docker image
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`): 3.4.18
- APISIX Dashboard version, if relevant: 2.13-centos (offical docker image)
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]