{"id":20879217,"url":"https://github.com/7c/telegraf-metrix","last_synced_at":"2026-04-19T16:35:18.074Z","repository":{"id":57065338,"uuid":"117836127","full_name":"7c/telegraf-metrix","owner":"7c","description":"Telegraf socker listener UDP Client","archived":false,"fork":false,"pushed_at":"2018-02-12T14:05:29.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T16:45:39.366Z","etag":null,"topics":["influxdb","metrics","socket","telegraf"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-17T12:55:34.000Z","updated_at":"2020-03-29T09:17:04.000Z","dependencies_parsed_at":"2022-08-24T14:01:29.048Z","dependency_job_id":null,"html_url":"https://github.com/7c/telegraf-metrix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/7c/telegraf-metrix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/7c","download_url":"https://codeload.github.com/7c/telegraf-metrix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/7c%2Ftelegraf-metrix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28057080,"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","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","metrics","socket","telegraf"],"created_at":"2024-11-18T07:15:35.961Z","updated_at":"2025-12-26T17:00:09.226Z","avatar_url":"https://github.com/7c.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Telegraf Metrix\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 0.0.14. 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. Timestamp is nano seconds precision. PHP does only understand microsecond. You may want to *1000 this value to convert to nano seconds\n\nI preper UDP protocol because php is stateless and not able to run async functions natively. 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\n\n## Install\n\n```composer require taskinosman/telegraf-metrix @dev```\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- target either has to be defined with all its components scheme://host:port or kept default\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- send() returns line protocol formatted or false by error\n- timestamp is optional,telegraf does this job for you if you omit\n\n\n```\n$metrix = new metrix(\"udp://127.0.0.1\");\n\nwhile(true) {\n\n    $metrix-\u003esend('Random Generator',\n            ['type'=\u003e'random'],\n            ['measurement 1 to 100'=\u003erand(1,100),'measurement 1 to 500'=\u003erand(1,500)]\n    );\n\n    $metrix-\u003esend('Memory',\n            ['from'=\u003e'php'],\n            ['usage'=\u003ememory_get_usage(),'peak'=\u003ememory_get_peak_usage()]\n    );\n\n    $metrix-\u003esend('Mixed',\n            ['from'=\u003e'key.subkey.lastkey'],\n            time()\n    );\n\n    sleep(1);\n}\n```\n## Pulse Feature (alpha)\nBasic pulse/bearthbeat function included. This function will send hearthbeats from the application with with given $appname as identifier to telegraf using udp. These pulses can be used to detect anomalies or down times of your application.\n\nGiven example will send a pulse/hearthbeat to telegraf every 15 seconds automatically\n```\n$metrix = new metrix(\"udp://127.0.0.1\");\n$metrix-\u003epulseEnable('example.php',15);\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","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F7c%2Ftelegraf-metrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F7c%2Ftelegraf-metrix/lists"}