{"id":17362473,"url":"https://github.com/akasprzok/sleipnir","last_synced_at":"2025-04-14T13:11:39.957Z","repository":{"id":37050146,"uuid":"497720823","full_name":"akasprzok/sleipnir","owner":"akasprzok","description":"A Grafana Loki client for Elixir","archived":false,"fork":false,"pushed_at":"2024-05-13T00:47:29.000Z","size":91,"stargazers_count":5,"open_issues_count":9,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T02:14:19.480Z","etag":null,"topics":["elixir","grafana","hex"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/akasprzok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-05-29T22:12:42.000Z","updated_at":"2024-04-29T21:45:47.000Z","dependencies_parsed_at":"2024-02-09T20:26:56.844Z","dependency_job_id":null,"html_url":"https://github.com/akasprzok/sleipnir","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":"0.11111111111111116","last_synced_commit":"8078b72a5a6f597efb733a968e2fc98fde7aaecf"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akasprzok%2Fsleipnir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akasprzok%2Fsleipnir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akasprzok%2Fsleipnir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akasprzok%2Fsleipnir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akasprzok","download_url":"https://codeload.github.com/akasprzok/sleipnir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543851,"owners_count":21121838,"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":["elixir","grafana","hex"],"created_at":"2024-10-15T19:38:36.864Z","updated_at":"2025-04-14T13:11:39.373Z","avatar_url":"https://github.com/akasprzok.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"![main](https://github.com/akasprzok/sleipnir/actions/workflows/main.yml/badge.svg?branch=main)\n[![Hex](https://img.shields.io/hexpm/v/sleipnir.svg)](https://hex.pm/packages/sleipnir/)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-informational.svg)](https://hexdocs.pm/sleipnir/)\n![License](https://img.shields.io/hexpm/l/sleipnir)\n[![Coverage Status](https://coveralls.io/repos/github/akasprzok/sleipnir/badge.svg?branch=main)](https://coveralls.io/github/akasprzok/sleipnir?branch=main)\n\n# Sleipnir\n\nA client for pushing logs to Grafana Loki.\n\n## Installation\n\nThe package can be installed\nby adding `sleipnir` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:sleipnir, \"~\u003e 0.1\"}\n  ]\nend\n```\n\nDocumentation may be found at \u003chttps://hexdocs.pm/sleipnir\u003e.\n\n## Usage\n\nThe `Sleipnir` module contains functions for creating Loki requests from your data, based on Grafana's protobufs. The important parts are:\n\n* `Entries`: timestamped strings\n* `Streams`: collections of entries under a common set of labels.\n* `PushRequests`: collections of streams, all pushed to Loki as a single request.\n\nHere's an example:\n\n```elixir\nentries = [\n  Sleipnir.entry(\"I am a log line\"),\n  Sleipnir.entry(\"I am another log line\")\n]\nlabels = [\n  {\"cluster\", \"ops-cluster-1\"},\n  {\"namespace\", \"loki-dev\"}\n]\nstream = Sleipnir.stream(entries, labels)\nrequest = Sleipnir.request(stream)\n```\n\nTo send the requests to Loki, Sleipnir includes a Tesla client that aims to provide sensible defaults.\n\n```elixir\nclient = Sleipnir.Client.Tesla.new(\"http://localhost:3100\", org_id: \"tenant1\")\n\n{:ok, %{status: 204}} = Sleipnir.push(client, request)\n```\n\n## Customizing the Client\n\nCustom clients can be implemented via the `[Sleipnir.Client](lib/sleipnir/client.ex)` protocol.\n\nA default implementation is provided for the `[Tesla.Client](/lib/sleipnir/client/tesla.ex) struct` which zips the push request and sends it to the standard `/loki/api/v1/push` path.\n\nAlso included is the `[Sleipnir.Client.Test client](lib/sleipnir/client/test.ex)` which sends any requests pushed to it to the provided pid. Useful for testing without the need for bypass or Tesla.Mock.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakasprzok%2Fsleipnir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakasprzok%2Fsleipnir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakasprzok%2Fsleipnir/lists"}