{"id":29273673,"url":"https://github.com/simplifi/ngx_lua_datadog","last_synced_at":"2025-07-05T02:36:33.459Z","repository":{"id":49808669,"uuid":"52311636","full_name":"simplifi/ngx_lua_datadog","owner":"simplifi","description":"Library to connect nginx lua script to Datadog/statsd logging","archived":false,"fork":false,"pushed_at":"2022-08-30T21:58:01.000Z","size":15,"stargazers_count":13,"open_issues_count":0,"forks_count":7,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-03-26T15:21:14.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplifi.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":"2016-02-22T22:43:03.000Z","updated_at":"2024-03-26T15:21:14.590Z","dependencies_parsed_at":"2023-01-16T21:15:57.281Z","dependency_job_id":null,"html_url":"https://github.com/simplifi/ngx_lua_datadog","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/simplifi/ngx_lua_datadog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fngx_lua_datadog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fngx_lua_datadog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fngx_lua_datadog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fngx_lua_datadog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplifi","download_url":"https://codeload.github.com/simplifi/ngx_lua_datadog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplifi%2Fngx_lua_datadog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263671876,"owners_count":23494055,"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":[],"created_at":"2025-07-05T02:36:32.734Z","updated_at":"2025-07-05T02:36:33.448Z","avatar_url":"https://github.com/simplifi.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ngx Lua Datadog connecter\n\nSimple libary extracted from the [Kong](https://github.com/Mashape/kong) project that allows for Datadog(statsd) collection from inside lua scripts running in nginx\n\n## Usage\n\nInclude the library code in your nginx configuration, usually inside the http block but outside the server block\n\n```\n# set path for lua libraries - ;; means append existing paths\nlua_package_path \"/path/to/ngx_lua_datadog/lib/?.lua;;\";\n```\n\nuse in a location stanza:\n \n```\nlocal conf = { host = \"127.0.0.1\", port = 8125, namespace = \"Lua_Stats_App\", timeout = 1}\nlocal statsd_logger = require \"ngx_lua_datadog\"\nlocal logger, err = statsd_logger:new(conf)\n\nif err then\n     ngx_log(ngx.ERR, \"failed to create Statsd logger: \", err)\nend\n\nif ( my_condition ) then\n     logger:counter(\"condition_matched\", 1, 1)\n     ngx.exit(204)\nelse\n     logger:counter(\"condition_not_matched\", 1, 1)\n     ngx.exit(200)\nend\n```\n\n## Configuration options\n| name | value |\n-------|--------\n| host | the ip or name of your statsd server |\n| port | the port number your statsd server runs on, default is 8125 |\n| timeout| the number of seconds for lua to wait to make the connection |\n| namespace | the string that all stat messages will be prefixed with |\n\n\n## Statistic Gathering\n\n```\n-- Simple counter \ncounter(stat, value, sample_rate, tags)\n\n-- Gauge\ngauge(stat, value, sample_rate, tags)\n\n-- Timer\ntimer(stat, ms, tags)\n\n-- Histogram\nhistogram(stat, value, tags)\n\n-- Meter\nmeter(stat, value, tags)\n\n-- Sets\nset(stat, value, tags)\n\n-- Distribution\ndistribution(stat, value, tags)\n```\nSample rates are your responsiblity to calculate.  If you tell it the sample rate is 0.10 (10 percent), then the **value** you send needs to be the sampled value.  e.g. If you've had 100 hits and you send a 0.20 sample rate, the value you send would be 20\n\n## Tag Format\n\nTags are sent as comma separated key value pairs with a colon deliminating the key from the value, e.g.\n\n```\ntags = \"country:china,datacenter:asia,account:mass_market\"\n\nlogger:counter(\"another_hit\", 1, 1, tags)\n```\n\n## Luarock creation\n\n1. Run `sh scripts/build_rock.sh \u003cversion\u003e` where version corresponds to the tag you want to build.  Ex. `sh scripts/build_rock.sh v0.1.0`.\n2. Upload the .src.rock file to the server (TBD)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplifi%2Fngx_lua_datadog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplifi%2Fngx_lua_datadog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplifi%2Fngx_lua_datadog/lists"}