ToddG
(Todd Gallant)
March 10, 2021, 7:17pm
1
Hi,
I am a graylog super newbie, so I am still learning. Currently I have one graylog server collecting logs from 4 production, 4 staging and 4 development servers.
When they report into graylog, everything is jumbled so there is no distinguishment other than the IP address, is there a way I can indicate in nginx when it sends it into the graylog, that its from production1?
Thanks!
How are you collecting the logs? Filebeat, syslog, something else? You might be able to add some tags, depeding on what youâre using.
ToddG
(Todd Gallant)
March 10, 2021, 8:05pm
3
in nginx.conf
log_format graylog2_json escape=json '{ âtimestampâ: â$time_iso8601â, â
'âremote_addrâ: â$remote_addrâ, â
'âbody_bytes_sentâ: $body_bytes_sent, â
'ârequest_timeâ: $request_time, â
'âresponse_statusâ: $status, â
'ârequestâ: â$requestâ, â
'ârequest_methodâ: â$request_methodâ, â
ââhostâ: â$hostâ,â
ââupstream_cache_statusâ: â$upstream_cache_statusâ,â
ââupstream_addrâ: â$upstream_addrâ,â
ââhttp_x_forwarded_forâ: â$http_x_forwarded_forâ,â
'âhttp_referrerâ: â$http_refererâ, â
ââhttp_user_agentâ: â$http_user_agentâ }â;
replace the hostnames with the IP or hostname of your Graylog2 server
access_log syslog:server=xx.xx.xx.xx:1514 graylog2_json;
error_log syslog:server=xx.xx.xx.xx:1514;
ToddG
(Todd Gallant)
March 11, 2021, 5:34pm
4
is there an easy way to tag these? or should I make 6 inputs, and update the nginx.configs to use the appropriate ports? I am using graylog 4.0.5.
ToddG
(Todd Gallant)
March 11, 2021, 8:30pm
5
I think i have it figured out now. sorry I said i was a super noob.
i went with
log_format graylog2_json escape=json '{ âtimestampâ: â$time_iso8601â, â
'âremote_addrâ: â$remote_addrâ, â
'âbody_bytes_sentâ: $body_bytes_sent, â
'ârequest_timeâ: $request_time, â
'âresponse_statusâ: $status, â
'ârequestâ: â$requestâ, â
'ârequest_methodâ: â$request_methodâ, â
ââhostâ: â$hostâ,â
ââupstream_cache_statusâ: â$upstream_cache_statusâ,â
ââupstream_addrâ: â$upstream_addrâ,â
ââhttp_x_forwarded_forâ: â$http_x_forwarded_forâ,â
'âhttp_referrerâ: â$http_refererâ, â
'âhttp_user_agentâ: â$http_user_agentâ, â
ââregionâ: âusâ,'
** ââenvâ: âdevâ }â;**
Just manually adding the region and env tags.
3 Likes
Nicely done, thanks for sharing the solution back with the community! And welcome!
1 Like
system
(system)
Closed
March 26, 2021, 9:38pm
7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.