{"id":15717791,"url":"https://github.com/xjewer/snitch","last_synced_at":"2025-03-30T21:26:47.499Z","repository":{"id":57523956,"uuid":"105085026","full_name":"xjewer/snitch","owner":"xjewer","description":"Snitch allows to parse log files and send statistics to statsd endpoint","archived":false,"fork":false,"pushed_at":"2022-11-02T10:20:49.000Z","size":701,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T01:29:27.386Z","etag":null,"topics":["balancer","go","golang","log","metrics","parser","statsd","statsite"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xjewer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-28T00:55:54.000Z","updated_at":"2017-09-28T00:58:36.000Z","dependencies_parsed_at":"2022-09-15T18:30:21.086Z","dependency_job_id":null,"html_url":"https://github.com/xjewer/snitch","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjewer%2Fsnitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjewer%2Fsnitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjewer%2Fsnitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjewer%2Fsnitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xjewer","download_url":"https://codeload.github.com/xjewer/snitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246381570,"owners_count":20768053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["balancer","go","golang","log","metrics","parser","statsd","statsite"],"created_at":"2024-10-03T21:51:21.085Z","updated_at":"2025-03-30T21:26:47.479Z","avatar_url":"https://github.com/xjewer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Snitch\n\n[![Travis](https://img.shields.io/travis/xjewer/snitch.svg)](https://travis-ci.org/xjewer/snitch)\n[![Coveralls](https://img.shields.io/coveralls/xjewer/snitch.svg)](https://coveralls.io/github/xjewer/snitch)\n[![Go Report Card](https://goreportcard.com/badge/github.com/xjewer/snitch)](https://goreportcard.com/report/github.com/xjewer/snitch)\n[![GitHub release](https://img.shields.io/github/release/xjewer/snitch.svg)](https://github.com/xjewer/snitch/releases)\n[![Docker Automated build](https://img.shields.io/docker/automated/xjewer/snitch.svg)](https://hub.docker.com/r/xjewer/snitch/)\n[![ImageLayers Layers](https://img.shields.io/imagelayers/layers/xjewer/snitch/latest.svg)](https://hub.docker.com/r/xjewer/snitch/)\n[![ImageLayers Size](https://img.shields.io/imagelayers/image-size/xjewer/snitch/latest.svg)](https://hub.docker.com/r/xjewer/snitch/)\n\nThis tool allows to parse log files and send statistics to statsd endpoint\n\n### Startup options\n\n* {string} `config` - configuration file\n* {string} `statsd` - statsd endpoint\n* {string} `prefix` - statsd global key prefix, e.g. `balancer.` \n* {int} `buffer` - buffer interval for metrics, `0` default: one metric - one request \n\n### Configuration file\n\nSnith has a particular configuration structure in yml:\n\n```\nsources:\n- source: name of source\n  file: ./test/log/test2.log\n  noFollow: false\n  mustExists: false\n  reOpen: true\n  prefix: \"balancer.%HOST%\"\n  delimiter: \"\\t\"\n  keys:\n    - key: All.$3.$6\n      count: true\n      timing: $4\n      delimiter: \" : \"\n    - key: All.$3.\n      timing: $10\n      delimiter: \" : \"\n```\n\nwhere is:\n\n* {string} `source`  - source name\n* {string} `file` - where the log file is\n* {boolean} `noFollow` - means no follow new lines that are written in the log file, if true\n* {boolean} `mustExists` - log file have to be existed, if true\n* {boolean} `reOpen` - re-open file, if true (e.g. log rotation)\n* {string} `prefix` - statsd key prefix, `%HOST%` is used as substitution a hostname\n* {string} `delimiter` - column delimiter in log files, it is reasonable to use `\\t` delimiter in log files\n\n* {[]key} `keys` - list of keys, which would be send to statsd \n    * {string} `key` - statsd metric key, $N - means column position\n    * {boolean} `count` - boolean, means  \n    * {string} `timing` - column with time (time should be in seconds, like 0.001 - means 1ms)  \n    * {string} `delimiter` - delimiter into the column, \n            e.g. nginx can to write in one column a few values from upstream the request was in   \n\n\nSnitch allows handle a few sources per instance\n\n### Docker build\n\nDocker build uses [multistage build](https://docs.docker.com/engine/userguide/eng-image/multistage-build/)\n\n```\ndocker build -t xjewer/snitch:{tag} .\n```\n\n\n### Run\n\n\n```\ndocker run --rm -v \"/var/log/nginx/balancer/:/var/log/:ro\" xjewer/snitch:0.1 -file /var/log/for_script.access.log -statsd graphite.local:8125 -buffer 10\n```\n\n### Benchmarks\n\nBenchmark line parsers is:\n\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/xjewer/snitch\nBenchmark_parser-4   \t 2000000\t       946 ns/op\t     416 B/op\t       8 allocs/op\nPASS\nok  \tgithub.com/xjewer/snitch\t2.890s\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjewer%2Fsnitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxjewer%2Fsnitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjewer%2Fsnitch/lists"}