Skip to content

Instantly share code, notes, and snippets.

View mcanaves's full-sized avatar

Mateu Cànaves mcanaves

  • Belvo
  • Pollença
View GitHub Profile
@mcanaves
mcanaves / datadog-nginx-json
Last active July 11, 2017 15:48 — forked from gane5h/datadog-nginx
Nginx json log parsing with datadog
"""
Thanks to gane5h for the original script.
Custom parser for JSON nginx log suitable for use by Datadog 'dogstreams'.
To use, add to datadog.conf as follows:
dogstreams: [path to ngnix log (e.g: "/var/log/nginx/access.log"]:[path to this python script (e.g
"/usr/share/datadog/agent/dogstream/nginx.py")]:[name of parsing method of this file ("parse")]
so, an example line would be:
dogstreams: /var/log/nginx/access.log:/usr/share/datadog/agent/dogstream/nginx.py:parse
Log of nginx should be defined like that:
log_format access_json '{ "time": "$time_local", '
@mcanaves
mcanaves / reset.sql
Last active January 25, 2017 14:54 — forked from tbarbugli/reset.sql
Reset all sequences for all schemas on a postgres db
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;