{"id":22882624,"url":"https://github.com/cloudfreexiao/skynet_influxdb","last_synced_at":"2025-04-14T21:11:39.996Z","repository":{"id":146275749,"uuid":"193852841","full_name":"cloudfreexiao/skynet_influxdb","owner":"cloudfreexiao","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-29T05:43:22.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T21:11:29.184Z","etag":null,"topics":["influxdb","skynet"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudfreexiao.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-26T07:30:38.000Z","updated_at":"2024-07-31T10:29:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"5391cedd-ebca-4ce4-a695-b72922b6a213","html_url":"https://github.com/cloudfreexiao/skynet_influxdb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudfreexiao%2Fskynet_influxdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudfreexiao%2Fskynet_influxdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudfreexiao%2Fskynet_influxdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudfreexiao%2Fskynet_influxdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudfreexiao","download_url":"https://codeload.github.com/cloudfreexiao/skynet_influxdb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961236,"owners_count":21189993,"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":["influxdb","skynet"],"created_at":"2024-12-13T18:18:37.672Z","updated_at":"2025-04-14T21:11:39.987Z","avatar_url":"https://github.com/cloudfreexiao.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Name\n\nskynet_infulxdb fork from [lua-resty-influx](https://github.com/p0pr0ck5/lua-resty-influx) skynet client writer for InfluxDB.\n\n## How to Use\n[examples](https://github.com/cloudfreexiao/skynet_influxdb/blob/master/examples/influxdb.lua)\n\n## Status\n\nThis library is in active development and is considered ready for production use.\n\n## Description\n\nThis library provides an OpenResty interface to write data points to an InfluxDB server via UDP and HTTP interfaces. Object-based and buffering per-worker interfaces are provided.\n\n## Synopsis\n\nObject interface:\n\n```lua\nhttp {\n\tserver {\n\t\taccess_by_lua_block {\n\t\t\tlocal i = require \"resty.influx.object\"\n\n\t\t\tlocal influx, err =i:new({\n\t\t\t\thost = \"127.0.0.1\",\n\t\t\t\tport = 8086,\n\t\t\t\tproto = \"http\",\n\t\t\t\tdb = \"db\",\n\t\t\t\thostname = \"localhost\",\n\t\t\t\tauth = \"user:password\",\n\t\t\t})\n\n\t\t\tif (not influx) then\n\t\t\t\tngx.say(err)\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinflux:set_measurement(\"foo\")\n\t\t\tinflux:add_tag(\"foo\", \"bar\")\n\t\t\tinflux:add_field(\"value\", 1)\n\t\t\tinflux:buffer()\n\n\t\t\t-- add and buffer additional data points\n\n\t\t\tlocal ok, err = influx:flush()\n\n\t\t\tif (not ok) then\n\t\t\t\tngx.say(err)\n\t\t\tend\n\t\t}\n\t}\n}\n```\n\nBuffering interface:\n\n```lua\nhttp {\n\tinit_worker_by_lua_block {\n\t\tlocal ibuf = require \"resty.influx.buffer\"\n\n\t\tlocal ok, err = ibuf.init({\n\t\t\thost = \"127.0.0.1\",\n\t\t\tport = 8089,\n\t\t\tproto = \"udp\",\n\t\t})\n\n\t\tif (not ok) then\n\t\t\tngx.log(ngx.ERR, err)\n\t\tend\n\t}\n\n\tserver {\n\t\taccess_by_lua_block {\n\t\t\tlocal ibuf = require \"resty.influx.buffer\"\n\n\t\t\tibuf.buffer({\n\t\t\t\tmeasurement = \"foo\",\n\t\t\t\ttags = {\n\t\t\t\t\t{ foo = \"bar\" }\n\t\t\t\t},\n\t\t\t\tfields = {\n\t\t\t\t\t{ value = 1 }\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\n\t\tlog_by_lua_block {\n\t\t\tlocal ibuf = require \"resty.influx.buffer\"\n\n\t\t\tibuf.flush()\n\t\t}\n\t}\n}\n```\n\n## Usage\n\n### Options\n\nlua-resty-influx provides a pure object-based interface, as well as a buffering interface that stores data points per-worker, and then buffers asynchronously via `ngx.timer.at`. Creation of the buffering interface should be handled in the `init_worker_by_lua` phase via the `resty.influx.buffer.init` function; creation of the object-oriented interface should be handled in your appropriate phase handler via `resty.influx.object:new`. In both cases, the following options are available:\n\n#### host\n\n*Default*: 127.0.0.1\n\nSets the host to which `ngx.socket.udp` and `resty.http` will attempt to connect.\n\n#### port\n\n*Default*: 8086\n\nSets the port to which `ngx.socket.udp` and `resty.http` will attempt to connect. Defaults to `8086` as the default protocol is HTTP.\n\n#### db\n\n*Default*: 'lua-resty-influx'\n\nSets the db to which `resty.http` will attempt to connect. This option is ignored when `udp` is the configured protocol.\n\n#### hostname\n\n*Default*: `host`\n\nSets the hostname to which `resty.http` will define the `Host` header for HTTP requests. By default, this is equal to the configured `host` option. This option is ignored when `udp` is the configured protocol.\n\n#### proto\n\n*Default*: http\n\nSets the protocol by which `resty.influx` will connect to the remote server. Note that UDP can present a significant performance improvement, particularly when sending many small sets of data points, at the cost of error handling and authentication.\n\n#### precision\n\n*Default*: ms\n\nSets the timestamp precision by which `resty.influx` will define timestamps. Currently, `ms`, `s`, and `none` are supported; when `none` is configured, no stamp will be sent as part of the line protocol message, and the remote Influx server will use nanosecond precision based on the server-local clock.\n\n#### ssl\n\n*Default*: false\n\nConfigures HTTP requests to perform a TLS handshake before sending data. This option is ignored when `udp` is the configured protocol.\n\n#### auth\n\n*Default*: ''\n\nSets the username and password presented to remote HTTP(S). This value must be given as a single string in the format `user:password`. This option is ignored when `udp` is the configured protocol.\n\n### Object-Oriented Interface\n\nThe following methods are available via the object interface:\n\n#### influx:set_measurement\n\n*Syntax*: influx:set_measurement(string)\n\nSets the measurement for the data point associated with the current object.\n\n#### influx:add_tag\n\n*Syntax* influx:add_tag(key, value)\n\nAdds a data point tag as a key-value pair. Keys and values are escaped according to (https://docs.influxdata.com/influxdb/v1.0/write_protocols/line_protocol_reference/).\n\n#### influx:add_field\n\n*Syntax*: influx:add_field(key, value)\n\nAdd a data point field as a key-value pair. Fields and values are escaped according to (https://docs.influxdata.com/influxdb/v1.0/write_protocols/line_protocol_reference/). Integer values (number values appended with an `i`) are properly interpolated.\n\n#### influx:stamp\n\n*Syntax*: influx:stamp(time?)\n\nStamps the data point associated with the current object, with an optional arbitrary value (must be provided as a number); otherwise, this stamps the object with the appropriate value based on the precision specified via the options given to `new` for the object interface.\n\n#### influx:clear\n\n*Syntax* influx:clear()\n\nClears the measurement, tags, and fields on the data point associated with the current object. Note that this is called internally when `buffer` or  `write` are called.\n\n#### influx:buffer\n\n*Syntax*: local ok, err = influx:buffer()\n\nBuffer the contents of the data point associated with the current object for later flushing. Returns true on success; otherwise, returns false and a string describing the error (such as invalid conditions under which to buffer).\n\n#### influx:flush\n\n*Syntax*: local ok, err = influx:flush()\n\nFlushes all buffered data points associated with the current object. Returns true on success; otherwise, returns false and a string describing the error (such as leftover data waiting to be buffered, or no available buffered data points).\n\n#### influx:write\n\n*Syntax* local ok, err = inflush:write()\n\nWrites the data point associated with the current object, without clearing the existing object buffer. This is essentially shorthand for calling `buffer` and `flush` on a single data point. Note that previously buffered data points still remain in the buffer, and must be sent out via `flush` if desired.\n\n### Buffering Interface\n\nThe following functions are available via the buffering interface:\n\n#### influx.buffer\n\n*Syntax*: influx.buffer(data_table)\n\nBuffers a new data point in the per-worker process buffer. `data_table` must be a table that contains the following keys:\n\n* `measurement`: String denoting the measurement of the data point\n* `tags`: Integer-indexed table containing tables of key-value pairs denoting the tag elements. See the synopsis for examples.\n* `fields`: Integer-indexed table containing tables of key-value pairs denoting the field elements. See the synopsis for examples.\n\nNote that currently the timestamp is automatically set with `ms` precision.\n\n#### influx.flush\n\n*Syntax* influx.flush()\n\nWrite all data points buffered in the current worker process to the configured influx host. Returns true on success; otherwise, returns false and a string describing the error from `ngx.timer.at`.\n\nThis operation returns immediately and runs asynchronously\n\n## License\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/\n\n## Bugs\n\nPlease report bugs by creating a ticket with the GitHub issue tracker.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudfreexiao%2Fskynet_influxdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudfreexiao%2Fskynet_influxdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudfreexiao%2Fskynet_influxdb/lists"}