{"id":22148356,"url":"https://github.com/dburriss/fennel","last_synced_at":"2025-07-26T02:32:17.632Z","repository":{"id":52483493,"uuid":"268289957","full_name":"dburriss/fennel","owner":"dburriss","description":"A Prometheus parsing and line generation library","archived":false,"fork":false,"pushed_at":"2023-10-15T12:06:40.000Z","size":37,"stargazers_count":14,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-10T10:51:56.243Z","etag":null,"topics":["domain-telemetry","parser","prometheus","team-devon"],"latest_commit_sha":null,"homepage":"","language":"F#","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/dburriss.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":"2020-05-31T13:50:21.000Z","updated_at":"2024-04-26T14:36:07.000Z","dependencies_parsed_at":"2024-06-21T15:19:45.853Z","dependency_job_id":"03e4fe86-2def-46e3-b858-3dadf084c31a","html_url":"https://github.com/dburriss/fennel","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/dburriss%2Ffennel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dburriss%2Ffennel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dburriss%2Ffennel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dburriss%2Ffennel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dburriss","download_url":"https://codeload.github.com/dburriss/fennel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227644645,"owners_count":17798212,"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":["domain-telemetry","parser","prometheus","team-devon"],"created_at":"2024-12-01T23:27:20.089Z","updated_at":"2024-12-01T23:27:21.237Z","avatar_url":"https://github.com/dburriss.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fennel\n\n*Fennel* - **A flowering plant in the carrot family**\n\nFennel is a simple library that speaks Promethean. If can translate prometheus log strings to typed metrics, as well as create metrics in well formatted Prometheus lines.\n\n## Why Fennel?\n\n\u003e But the noble son of Iapetus outwitted him and stole the far-seen gleam of unwearying fire in a hollow fennel stalk - Hesiod in the Theogony\n\nThe myth has it that Prometheus stole fire from Zeus by smuggling an ember in a hollow fennel stalk.\n\nIf you are wondering more about why I created this than about the name, it is simple. I was looking for something that just allowed me to create Prometheus log lines as strings. \nI also wanted to be able to parse Prometheus logs. Circa 2019 when I looked for this all I found were libraries that tied very deeply into ASP.NET Core.\nI had been looking for an excuse to play with a parsing library like FParsec... and here we are.\n\n## Nuget\n\nAvailable on [Nuget.org](https://www.nuget.org/packages/Fennel/)\n\n### Nuget Package Manger\n\n`Install-Package Fennel`\n\n### .NET CLI\n\n`dotnet add package Fennel`\n\n### PackageReference\n\n`\u003cPackageReference Include=\"Fennel\" /\u003e`\n\n### Paket\n\n`paket add Fennel`\n\n## Usage\n\n### Translating text to Types\n\nAssuming we have the following Prometheus logs as `input`:\n\n```text\n# Finally a summary, which has a complex representation, too:\n# HELP rpc_duration_seconds A summary of the RPC duration in seconds.\n# TYPE rpc_duration_seconds summary\nrpc_duration_seconds{quantile=\"0.01\"} 3102\nrpc_duration_seconds{quantile=\"0.05\"} 3272\nrpc_duration_seconds{quantile=\"0.5\"} 4773\nrpc_duration_seconds{quantile=\"0.9\"} 9001\nrpc_duration_seconds{quantile=\"0.99\"} 76656\nrpc_duration_seconds_sum 1.7560473e+07\nrpc_duration_seconds_count 2693\n```\n\nYou can break the result down into individually parsed lines.\n\n#### F#\n\n```f#\nopen Fennel\n\nlet lines = Prometheus.parseText input\n```\n\nEach line has multiple possibilities:\n\n```f#\nmatch line with\n| Help (name, doc) -\u003e printfn \"Help line %A\" (name, doc)\n| Comment txt -\u003e printfn \"Comment line %s\" txt\n| Type (name, t) -\u003e printfn \"Type line %A\" (name, t)\n| Metric m -\u003e printfn \"Metric line %A\" m\n| Blank -\u003e printfn \"Blank line\"\n```\n\n#### C#\n\n```c#\nusing Fennel.CSharp;\n\nvar lines = Prometheus.ParseText(input);\n```\n\nOr you can parse an individual line:\n\n```c#\nvar input = \"http_requests_total{method=\\\"post\\\",code=\\\"200\\\"} 1027 1395066363000\";\nvar result = Prometheus.ParseLine(input);\nif(result.IsMetric)\n{\n    var metric = result as Metric;\n}\n```\n\n### Metric to string\n\nYou can also create correctly formatted Prometheus strings for `comment`, `help`, and `metric` lines.\n\n#### F#\n\n```f#\nopen Fennel\n\nlet prometheusString = Prometheus.metric \"http_requests_total\" 1027. [(\"method\",\"post\");(\"code\",\"200\")] DateTimeOffset.UtcNow\n```\n\n#### C#\n\n```c#\nusing Fennel.CSharp;\n\nvar labels = new Dictionary\u003cstring, string\u003e{ {\"method\", \"post\"}, {\"code\", \"200\"} };\nvar prometheusString = Prometheus.Metric(\"http_requests_total\", 1027, labels, DateTimeOffset.UtcNow);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdburriss%2Ffennel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdburriss%2Ffennel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdburriss%2Ffennel/lists"}