{"id":21056922,"url":"https://github.com/fluent-plugins-nursery/fluent-plugin-stats","last_synced_at":"2025-05-15T23:33:33.827Z","repository":{"id":8321284,"uuid":"9871698","full_name":"fluent-plugins-nursery/fluent-plugin-stats","owner":"fluent-plugins-nursery","description":"Fluentd plugin to calculate statistics such as sum, max, min, avg.","archived":false,"fork":false,"pushed_at":"2017-09-14T19:33:30.000Z","size":44,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-15T13:22:47.173Z","etag":null,"topics":["fluentd-output-plugin","fluentd-plugin","v10","v12","v14"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/fluent-plugins-nursery.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-05-05T17:07:33.000Z","updated_at":"2024-06-18T11:55:42.000Z","dependencies_parsed_at":"2022-08-07T02:15:25.461Z","dependency_job_id":null,"html_url":"https://github.com/fluent-plugins-nursery/fluent-plugin-stats","commit_stats":null,"previous_names":["sonots/fluent-plugin-stats"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-stats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-stats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-stats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-stats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluent-plugins-nursery","download_url":"https://codeload.github.com/fluent-plugins-nursery/fluent-plugin-stats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442429,"owners_count":22071864,"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":["fluentd-output-plugin","fluentd-plugin","v10","v12","v14"],"created_at":"2024-11-19T16:54:56.986Z","updated_at":"2025-05-15T23:33:28.771Z","avatar_url":"https://github.com/fluent-plugins-nursery.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluent-plugin-stats [![Build Status](https://secure.travis-ci.org/sonots/fluent-plugin-stats.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-stats)\n\nFluentd plugin to calculate statistics such as sum, max, min, avg.\n\n## Configuration\n\n### Example 1\n\nGet sum for xxx\\_count, max for xxx\\_max, min for xxx\\_min, avg for xxx\\_avg\n\n    \u003cmatch foo.**\u003e\n      type stats\n      interval 5s\n      add_tag_prefix stats\n\n      sum .*_count$\n      max .*_max$\n      min .*_min$\n      avg .*_avg$\n    \u003c/match\u003e\n\nAssuming following inputs are coming:\n\n    foo.bar: {\"4xx_count\":1,\"5xx_count\":2\",\"reqtime_max\":12083,\"reqtime_min\":10,\"reqtime_avg\":240.46}\n    foo.bar: {\"4xx_count\":4,\"5xx_count\":2\",\"reqtime_max\":24831,\"reqtime_min\":82,\"reqtime_avg\":300.46}\n\nthen output bocomes as belows: \n\n    stats.foo.bar: {\"4xx_count\":5,\"5xx_count\":4\",\"reqtime_max\":24831,\"reqtime_min\":10,\"reqtime_avg\":270.46}\n\n### Example 2\n\nGet sum, max, min, avg for the same key\n\n    \u003cmatch foo.**\u003e\n      type stats\n      interval 5s\n      add_tag_prefix stats\n\n      sum ^reqtime$\n      max ^reqtime$\n      min ^reqtime$\n      avg ^reqtime$\n      sum_suffix _sum\n      max_suffix _max\n      min_suffix _min\n      avg_suffix _avg\n    \u003c/match\u003e\n\nAssuming following inputs are coming:\n\n    foo.bar: {\"reqtime\":1.000}\n    foo.bar: {\"reqtime\":2.000}\n\nthen output bocomes as belows: \n\n    stats.foo.bar: {\"reqtime_sum\":3.000,\"reqtime_max\":2.000,\"reqtime_min\":1.000,\"reqtime_avg\":1.500}\n\n## Parameters\n\n- sum, min, max, avg\n\n    Target of calculation. Specify input keys by a regular expression\n\n- sum\\_keys, min\\_keys, max\\_keys, avg\\_keys\n\n    Target of calculation. Specify input keys by a string separated by , (comma) such as\n\n        sum_keys 4xx_count,5xx_count\n\n- sum\\_suffix, min\\_suffix, max\\_suffix, avg\\_suffix\n\n    Add a suffix to keys of the output record\n\n- interval\n\n    The interval to calculate in seconds. Default is 5s. \n\n- tag\n\n    The output tag name. Required for aggregate `all`. \n\n- add_tag_prefix\n\n    Add tag prefix for output message. Default: 'stats'\n\n- remove_tag_prefix\n\n    Remove tag prefix for output message. \n\n- add_tag_suffix\n\n    Add tag suffix for output message.\n\n- remove_tag_suffix\n\n    Remove tag suffix for output message. \n\n* remove_tag_slice *min..max*\n\n    Remove tag parts by slice function. FYI: This option behaves like `tag.split('.').slice(min..max)`.\n\n    For example,\n\n        remove_tag_slice 0..-2\n\n    changes an input tag `foo.bar.host1` to `foo.bar`.\n\n* aggregate\n\n    Aggregation unit. One of `all`, `in_tag`, `out_tag` can be specified. Default is `in_tag`.\n\n    * `all` calculate stats for all input messages and emit one message in each interval.\n    * `in_tag` calculate stats for each input tag seperately.\n    * `out_tag` calculate stats for for each tag *modified* by `add_tag_prefix`, `remove_tag_prefix`, or `remove_tag_slice`.\n\n- store_file\n\n    Store internal data into a file of the given path on shutdown, and load on starting.\n\n- zero_emit\n\n    Emit 0 on the next interval. This is useful for some software which requires to reset data such as [GrowthForecast](http://kazeburo.github.io/GrowthForecast/) . \n\n        stats.foo.bar: {\"4xx_count\":5,\"5xx_count\":4\",\"reqtime_max\":24831,\"reqtime_min\":10,\"reqtime_avg\":270.46}\n        # after @interval later\n        stats.foo.bar: {\"4xx_count\":0,\"5xx_count\":0\",\"reqtime_max\":0,\"reqtime_min\":0,\"reqtime_avg\":0}\n\n## ChangeLog\n\nSee [CHANGELOG.md](CHANGELOG.md) for details.\n\n## ToDo\n\nGet the number of denominator to calculate `avg` from input json field. \n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new [Pull Request](../../pull/new/master)\n\n## Copyright\n\nCopyright (c) 2013 Naotoshi Seo. See [LICENSE](LICENSE) for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-stats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-stats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-stats/lists"}