Skip to content

Instantly share code, notes, and snippets.

@llowder
Created June 12, 2012 21:06
Show Gist options
  • Select an option

  • Save llowder/2920139 to your computer and use it in GitHub Desktop.

Select an option

Save llowder/2920139 to your computer and use it in GitHub Desktop.
shell script snippet to fix severity levels
count=`curl -s -XPOST 'http://localhost:9200/graylog2/_count?pretty=true' -d '{"term" : { "message" : "info" } }' | sed -n 's/.*count"[ ]:[ ]\([0-9]*\),/\1/p'`
echo "Fixing ${count} INFO messages"
if [ $count -ne 0 ]; then
for i in `curl -s -XPOST 'http://localhost:9200/graylog2/_search?pretty=true' -d "{\"fields\" : [\"_id\"], \"from\" : 0, \"size\" : ${count}, \"query\" : {\"term\" : { \"message\" : \"info\" } } }" | sed -n 's/"_id".*"\(.*\)",/\1/p'`
do
echo "i is: ${i}"
curl -XPOST "http://localhost:9200/graylog2/message/${i}/_update?pretty=true" -d '{ "script" : "ctx._source.level = 6" }'
echo ""
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment