Skip to content

Instantly share code, notes, and snippets.

@josefglatz
Created June 15, 2020 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josefglatz/c30aa0cd12b307faac85570671275fbd to your computer and use it in GitHub Desktop.
Save josefglatz/c30aa0cd12b307faac85570671275fbd to your computer and use it in GitHub Desktop.
Setup graylog general inputs for e.g. docker containers
#!/bin/bash
IP_ADDRESS=localhost
GRAYLOG3_URL="http://${IP_ADDRESS}:9000"
GRAYLOG3_INPUT_GELF_TCP='
{
"global": "true",
"title": "Gelf TCP",
"configuration": {
"port": 12201,
"bind_address": "0.0.0.0"
},
"type": "org.graylog2.inputs.gelf.tcp.GELFTCPInput"
}'
GRAYLOG3_INPUT_GELF_UDP='
{
"global": "true",
"title": "Gelf UDP",
"configuration": {
"port": 12201,
"bind_address": "0.0.0.0"
},
"type": "org.graylog2.inputs.gelf.udp.GELFUDPInput"
}'
INPUTS=$(curl -u admin:admin -X GET -H "Content-Type: application/json" -H 'X-Requested-By: cli' ${GRAYLOG3_URL}/api/system/inputs 2>/dev/null)
STREAMS=$(curl -u admin:admin -X GET -H "Content-Type: application/json" -H 'X-Requested-By: cli' ${GRAYLOG3_URL}/streams 2>/dev/null)
if [ $(echo $INPUTS | grep -c "GELF TCP") != "1" ]; then
curl -u admin:admin -s -X POST -H "Content-Type: application/json" -H 'X-Requested-By: cli' -d "${GRAYLOG3_INPUT_GELF_TCP}" ${GRAYLOG3_URL}/api/system/inputs > /dev/null
fi
if [ $(echo $INPUTS | grep -c "GELF UDP") != "1" ]; then
curl -u admin:admin -s -X POST -H "Content-Type: application/json" -H 'X-Requested-By: cli' -d "${GRAYLOG3_INPUT_GELF_UDP}" ${GRAYLOG3_URL}/api/system/inputs > /dev/null
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment