{"id":30672723,"url":"https://github.com/oxide-byte/rust-observability","last_synced_at":"2025-09-01T05:07:39.757Z","repository":{"id":311221433,"uuid":"1042914473","full_name":"oxide-byte/rust-observability","owner":"oxide-byte","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-22T20:57:24.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-22T22:52:53.033Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/oxide-byte.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,"zenodo":null}},"created_at":"2025-08-22T19:42:39.000Z","updated_at":"2025-08-22T20:57:27.000Z","dependencies_parsed_at":"2025-08-22T22:53:04.900Z","dependency_job_id":"343ec45e-3006-4492-ab82-bf4bba009639","html_url":"https://github.com/oxide-byte/rust-observability","commit_stats":null,"previous_names":["oxide-byte/rust-observability"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/oxide-byte/rust-observability","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxide-byte%2Frust-observability","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxide-byte%2Frust-observability/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxide-byte%2Frust-observability/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxide-byte%2Frust-observability/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxide-byte","download_url":"https://codeload.github.com/oxide-byte/rust-observability/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxide-byte%2Frust-observability/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273077112,"owners_count":25041357,"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-09-01T02:00:09.058Z","response_time":120,"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":[],"created_at":"2025-09-01T05:07:39.083Z","updated_at":"2025-09-01T05:07:39.741Z","avatar_url":"https://github.com/oxide-byte.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Observability\n\n## Introduction\n\nA service that is not observed, is lost in the universe of distributed systems. This POC-project is a small sample to\nshow how keep track on your Rust Service. The Service and all the infrastructure is dockerized, you can simply start up\nall with \"docker-compose up\"\n\nThe project demonstrates two methods of log collection:\n\n1. Via `tracing-loki` directly from the application.\n\n2. Via Promtail scraping Docker logs.\n\nIt also showcases a robust metrics collection system, capturing both application-level metrics (HTTP requests, handler\ndurations) and process-level metrics (CPU, memory).\n\nThe project uses a modern stack (Axum, Tokio, OpenTelemetry) and integrates the standard observability tools (\nPrometheus, Grafana, Loki)\n\nA small Screenshot the observed service in Grafana:\n\n![alt text](doc/images/sample.png \"sample\")\n\nLogs:\n\n![alt text](doc/images/log.png \"log\")\n\n## Links\n\nThe current links available by the application:\n\nThe Rust Service:\n\n* Hosted on port 8080: http://127.0.0.1:8080/\n* API: http://127.0.0.1:8080/api/demo for generating log entries\n* Metrics: http://127.0.0.1:8080/metrics for collecting the current metrics of the Rust Service\n* Health: http://127.0.0.1:8080/metrics for healths status\n\nPrometheus:\n\n* http://127.0.0.1:9090/\n\nGrafana:\n\n* http://127.0.0.1:3000/\n\nLoki:\n\n* A simple query on Loki: http://127.0.0.1:3100/loki/api/v1/query?query={job=\"docker-logs\"}\n\n* A query with a range option:\n    - http://127.0.0.1:3100/loki/api/v1/query_range?query={job=\"docker-logs\"}\u0026limit=1000\u0026direction=backward\u0026start=\u003c\n      rfc3339_or_unix_ns\u003e\u0026end=\u003crfc3339_or_unix_ns\u003e\n\n## Architecture: Logs and Metrics Flow\n\nA little Flowchart for illustrating how the different logs are collected and transmitted to the different systems:\n\n```mermaid\nflowchart LR\n  subgraph Docker Network\n    A[Rust-Axum-Server]\n    D[(Docker JSON logs\u003cbr/\u003e/var/lib/docker/containers/*/*-json.log)]\n    PT[Promtail]\n    L[Loki]\n    PR[Prometheus]\n    G[Grafana]\n  end\n\n  %% Logs flow (1)\n  A -- stdout logs --\u003e D\n  D -- tail --\u003e PT\n  PT -- push /loki/api/v1/push --\u003e L\n  G -- query (Loki datasource) --\u003e L\n\n  %% Logs flow (2)\n  A -- push (tracing-loki) --\u003e L\n\n  %% Metrics flow\n  A -- scrape /metrics --\u003e PR\n  PT -- scrape /metrics (9080) --\u003e PR\n  L -- scrape /metrics (3100) --\u003e PR\n  G -- query (Prometheus datasource) --\u003e PR\n```\n\nNotes:\n\n- Promtail collects logs from Docker JSON log files and pushes them to Loki. Loki does not pull logs from the app. (\n  Solution 1)\n- Cargo tracing-loki, declare appender, push to Loki (Solution 2)\n- Prometheus scrapes metrics from the app, Promtail, and Loki; logs are not stored in Prometheus.\n- Grafana uses the Loki datasource for logs and the Prometheus datasource for metrics.\n\n## Docker-Compose\n\nStarting the application and all infrastructure components with:\n\n```shell\ndocker-compose up\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxide-byte%2Frust-observability","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxide-byte%2Frust-observability","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxide-byte%2Frust-observability/lists"}