{"id":37706974,"url":"https://github.com/harshittrivedi78/prometheus","last_synced_at":"2026-01-16T13:09:44.206Z","repository":{"id":47241116,"uuid":"261549813","full_name":"harshittrivedi78/prometheus","owner":"harshittrivedi78","description":"Python prometheus library for django and django rest framework.","archived":false,"fork":false,"pushed_at":"2021-09-07T09:41:06.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-29T03:18:52.237Z","etag":null,"topics":["django","django-rest-framework","metrics","monitoring","prometheus","prometheus-client","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harshittrivedi78.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":"2020-05-05T18:17:38.000Z","updated_at":"2023-11-25T01:07:40.000Z","dependencies_parsed_at":"2022-09-10T00:40:15.602Z","dependency_job_id":null,"html_url":"https://github.com/harshittrivedi78/prometheus","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/harshittrivedi78/prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshittrivedi78%2Fprometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshittrivedi78%2Fprometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshittrivedi78%2Fprometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshittrivedi78%2Fprometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harshittrivedi78","download_url":"https://codeload.github.com/harshittrivedi78/prometheus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshittrivedi78%2Fprometheus/sbom","scorecard":{"id":456414,"data":{"date":"2025-08-11","repo":{"name":"github.com/harshittrivedi78/prometheus","commit":"0d1be5c734ceb36b05ef1fbb7901d0910f13410f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/24 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"24 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2018-6 / GHSA-2f9x-5v75-3qv4","Warn: Project is vulnerable to: PYSEC-2017-9 / GHSA-37hp-765x-j95x","Warn: Project is vulnerable to: PYSEC-2016-18 / GHSA-3f2c-jm6v-cr35","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2015-11 / GHSA-6wcr-wcqm-3mfh","Warn: Project is vulnerable to: PYSEC-2015-19 / GHSA-6wgp-fwfm-mxp3","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2015-21 / GHSA-cqf7-ff9h-7967","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2016-16 / GHSA-fp6p-5xvw-m74f","Warn: Project is vulnerable to: PYSEC-2017-10 / GHSA-h4hv-m4h4-mhwg","Warn: Project is vulnerable to: PYSEC-2015-20 / GHSA-h582-2pch-3xv3","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2016-17 / GHSA-mv8g-fhh6-6267","Warn: Project is vulnerable to: PYSEC-2015-22 / GHSA-pgxh-wfw4-jx2v","Warn: Project is vulnerable to: PYSEC-2016-15 / GHSA-pw27-w7w4-9qc7","Warn: Project is vulnerable to: PYSEC-2015-10 / GHSA-q5qw-4364-5hhm","Warn: Project is vulnerable to: PYSEC-2018-5 / GHSA-r28v-mw67-m5p9","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2020-263 / GHSA-fx83-3ph3-9j2q","Warn: Project is vulnerable to: GHSA-gw84-84pc-xp82"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T09:48:19.881Z","repository_id":47241116,"created_at":"2025-08-19T09:48:19.881Z","updated_at":"2025-08-19T09:48:19.881Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["django","django-rest-framework","metrics","monitoring","prometheus","prometheus-client","python"],"created_at":"2026-01-16T13:09:44.144Z","updated_at":"2026-01-16T13:09:44.200Z","avatar_url":"https://github.com/harshittrivedi78.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prometheus\nPython prometheus library for django and django rest framework.\nThis helps in monitoring the application on a granular level. You can customize which part \nof the application you want to monitor. Through this you can monitor a REST API, a python \nfunction , a code segment.\n\n## Usage\n\n### Requirements\n\n* Django \u003e= 1.8\n* djangorestframework \u003e= 3.0\n* prometheus_client \u003e= 0.7.1\n\n### Installation\n\nInstall with:\n\n```shell\npip install prometheus-python\n```\n\nOr, if you're using a development version cloned from this repository:\n\n```shell\ngit clone https://github.com/harshittrivedi78/prometheus.git\npython prometheus/setup.py install\n```\nThis will install Django \u003e= 1.8 and djangorestframework \u003e= 3.0 and [prometheus_client](https://github.com/prometheus/client_python) as a dependency if not installed already.\n### Quickstart\n\nIn your settings.py:\n\n```python\nINSTALLED_APPS = [\n   ...\n   'prometheus',\n   ...\n]\n```\n\nIn your urls.py:\n\n```python\nurlpatterns = [\n    ...\n    url('', include('prometheus.urls')),\n]\n```\n\nIn your views.py:\n\n```python\nfrom rest_framework import generics, status\nfrom rest_framework.response import Response\nfrom prometheus import monitor\n\nclass TestAPIView(generics.RetrieveAPIView):\n    \n    @monitor(app_name=\"test\") # app_name should be unique through out the application.\n    def retrieve(self, request, *args, **kwargs):\n        data = {}\n        return Response(data, status=status.HTTP_200_OK)\n```\n\nSo as you can see in the above example I have decorated the retrieve function by our monitor\ndecorator which will provide monitoring metrics for this function only. And you can identify\nhow much time this function is taking to execute, how many requests are in progress currently, \nhow many request totally served till now.\n\nMetrics are exposed to:\n```\nhttp://localhost:8000/metrics\n```\n\n### Default list of monitored metrics \n```\n* request_count\n* request_latency\n* request_in_progress\n* response_by_status_total\n```\n\n### Configuration\nPrometheus uses Histogram based grouping for monitoring latencies. The default\nbuckets are here: https://github.com/prometheus/client_python/blob/master/prometheus_client/core.py\n\nYou can define custom buckets for latency, adding more buckets decreases performance but\nincreases accuracy: https://prometheus.io/docs/practices/histograms/\n\nIn your settings.py\n```python\nPROMETHEUS_LATENCY_BUCKETS = (.1, .2, .5, .6, .8, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.5, 9.0, 12.0, 15.0, 20.0, 30.0, float(\"inf\"))\n```\n\n### Monitor in multiprocess mode (uWSGI, Gunicorn)\nIn your settings.py\n```python\nPROMETHEUS_MULTIPROC_MODE = True # default is False\nPROMETHEUS_MULTIPROC_DIR = /path/to/prometheus_multiproc_dir # default it will save db files in prometheus/multiproc_dir/\n```\n### Monitoring of Batch Jobs\nSo in prometheus legacy system we have to collect the metrics and push those metrics to the pushgateway and then prometheus server has to scrape those metrics from push gateway. But now I have modified this apporach. Now I have exposed an endpoint in this prometheus client to push your metrics.\n\nSo as usual you must be running prometheus client with server (Django, Django Rest Framework).\n\nIn settings.py: these settings is actually where your server is running.\n```python\nPROMETHEUS_METRICS_PROTOCOL = \"HTTP\" # or HTTPS\nPROMETHEUS_METRICS_HOST = \"127.0.0.1\"\nPROMETHEUS_METRICS_PORT = \"8000\"\nPROMETHEUS_PUSH_METRICS_URL = \"/push/metrics\"\n```\nIn your any batch_job.py\n```python\nfrom prometheus import batch_monitor\n\n@batch_monitor(app_name=\"sum\")\ndef sum(a,b):\n   return a+b\n   \nsum(10, 20)\n```\nSo here this batch_monitor decorator will push the metrics to you server and add monitored metrics into your server's metrics.\n\n### Default Batch Job Monitored Metrics\n```\n* request_count\n* time_taken\n* last_success\n* Last_failure\n```\nThese metrics can be seen at `/metrics` endpoint.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshittrivedi78%2Fprometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshittrivedi78%2Fprometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshittrivedi78%2Fprometheus/lists"}