{"id":20879209,"url":"https://github.com/7c/telegraf-metrix-node","last_synced_at":"2025-05-12T16:31:20.485Z","repository":{"id":57388504,"uuid":"118066062","full_name":"7c/telegraf-metrix-node","owner":"7c","description":"Telegraf UDP Metrics client for Nodejs","archived":false,"fork":false,"pushed_at":"2025-02-18T22:07:37.000Z","size":5,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-21T09:19:52.260Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/7c.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":"2018-01-19T02:31:31.000Z","updated_at":"2025-02-18T22:07:41.000Z","dependencies_parsed_at":"2022-09-07T13:21:59.027Z","dependency_job_id":null,"html_url":"https://github.com/7c/telegraf-metrix-node","commit_stats":null,"previous_names":["taskinosman/telegraf-metrix-node"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7c","download_url":"https://codeload.github.com/7c/telegraf-metrix-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253776814,"owners_count":21962563,"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":"2024-11-18T07:15:34.531Z","updated_at":"2025-05-12T16:31:20.224Z","avatar_url":"https://github.com/7c.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegraf Metrix-Node\n\nSupports telegraf line protocol and sends metrics over udp (for now). Line protocol uses nanosecond precision timestamp. You can add nanosecond timestamp as last parameter optionally since the version 1.1.4. If you omit this timestamp telegraf will add it based on its local time to your data. Sometimes you may want to add this timestamp to send data from the past\n\nI preper UDP protocol because its fault-tolerant, I do not want to block my operations with TCP which has a handshake and many checks\n\nPlanning to support TCP by next versions. Also maintaining PHP version of metrix\n\n## Install\n\nnpm install telegraf-metrix-node --save\n\n## Telegraf Configuration\nEnable [[inputs.socket_listener]] inside telegraf.conf with a service address like udp://:8094 to enable UDP from 0.0.0.0. You may also choose to activate UDP for 127.0.0.1 which is recommended way\n\n## Usage\n- default target is udp://127.0.0.1:8094\n- scheme must be defined if default value is not taken\n- target structure is scheme://host:port\n- measurement name: ^[a-zA-Z0-9_, .-]+$\n- tag keys, tag values: ^[a-zA-Z0-9_,. =]+$\n- tags are optional\n- fields are optional\n- time will be stamped from telegraf (for now)\n\n```\nvar Metrix = require(\"telegraf-metrix-node\");\nvar metrix = new Metrix(\"udp://127.0.0.1:8094\",'myapp'); \n\nfunction tick() {\n    setTimeout(()=\u003e{\n        console.log(\"Sending \u003e\",\n        metrix.send(\"Random Generator\",{type:\"random\"},{\n            'rand 1..100':Math.random()*100,\n            'rand 1..500':Math.random()*500,\n        }));\n        tick();\n    },1000);\n}\n\ntick();\n```\n\n\n## Pulse Feature\nbeta pulse feature is implemented. Pulse will send heartbeats to telegraf, this way you can detect if an app or part of an app has stopped working. You can either use .pulse() method or .pulseAuto() to make it automatic. Please do not call pulseAuto more then 10 times. .pulse() is designed to be called inside your loops to send manual signals. Pulse supports throttling to avoid sending heartbeats more then necessary. Default value is 1000 (ms) which will send the HB only every 1000ms even though you send it from a fast loop.\n\nI recommend using AppName from the constructor `constructor(target=\"udp://127.0.0.1\", appName=false, appVersion=false, debug = false)` which will be attached to the heartbeat automatically. If you do not specify appName it will try to find corresponding package.json to the host app but most of the time it might fail.\n\n```\nmetrix.pulseAuto('myappPulse',1500);\nwhile(true) {\n    metrix.pulse('mainloop',2000);\n}\n```\n\n## Line protocol details\nhttps://docs.influxdata.com/influxdb/v0.9/write_protocols/line/\n\n[key] [tags] [fields] [timestamp]\n\n```\nFields are key-value metrics associated with the measurement. Every line must have at least one field. Multiple fields must be separated with commas and not spaces.\n\nField keys are always strings and follow the same syntactical rules as described above for tag keys and values. Field values can be one of four types. The first value written for a given field on a given measurement defines the type of that field for all series under that measurement.\n\nIntegers are numeric values that do not include a decimal and are followed by a trailing i when inserted (e.g. 1i, 345i, 2015i, -10i). Note that all values must have a trailing i. If they do not they will be written as floats.\n\nFloats are numeric values that are not followed by a trailing i. (e.g. 1, 1.0, -3.14, 6.0e5, 10).\n\nBoolean values indicate true or false. Valid boolean strings are (t, T, true, True, TRUE, f, F, false, False and FALSE).\n\nStrings are text values. All string values must be surrounded in double-quotes \". If the string contains a double-quote, it must be escaped with a backslash, e.g. \\\".\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Ftelegraf-metrix-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7c%2Ftelegraf-metrix-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Ftelegraf-metrix-node/lists"}