Skip to main content

monitor api request count

Project description

Django-request-counter

Install this app to get django api request count

Installation

Install my-project with pip

  pip install request-counter

In settings.py add below Add the app in installed apps

INSTALLED_APPS = [
    ...
    "request_counter",
]

Add middleware

MIDDLEWARE = [
    ...
    "request_counter.middlewares.APICounterMiddleware",
]

To check using API Add

urlpartterns = [
    ...
    path("",include("request_counter.urls")),
]

Set Redis Url

# REDIS_URL = "redis://localhost:6379/7" # by default
REDIS_URL = "<your redis url path>"
API_START_PATH = "/api/" # by default set "" for monitoring all path
API_START_PATH = "<your starting path>"

You need to setup cron to periodically save the data into default database

python manage.py store_api_count

Now make api request with admin user

curl --location '<base-url>/api-count/' \
--header '<your authentication header>'

curl --location '<base-url>/api-count/redis' \
--header '<your authentication header>'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

request-counter-1.3.0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

request_counter-1.3.0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page