Skip to content

Commit

Permalink
Basic Prometheus /metrics added (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
nghduc97 authored Feb 18, 2025
1 parent a96ab4f commit 9147575
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ You can pre-save all of your Apprise configuration and/or set of Apprise URLs an
| `/notify/{KEY}` | POST | Sends notification(s) to all of the end points you've previously configured associated with a *{KEY}*.<br/>*Payload Parameters*<br/>📌 **body**: Your message body. This is the *only* required field.<br/>📌 **title**: Optionally define a title to go along with the *body*.<br/>📌 **type**: Defines the message type you want to send as. The valid options are `info`, `success`, `warning`, and `failure`. If no *type* is specified then `info` is the default value used.<br/>📌 **tag**: Optionally notify only those tagged accordingly. Use a comma (`,`) to `OR` your tags and a space (` `) to `AND` them. More details on this can be seen documented below.<br/>📌 **format**: Optionally identify the text format of the data you're feeding Apprise. The valid options are `text`, `markdown`, `html`. The default value if nothing is specified is `text`.
| `/json/urls/{KEY}` | GET | Returns a JSON response object that contains all of the URLS and Tags associated with the key specified.
| `/details` | GET | Set the `Accept` Header to `application/json` and retrieve a JSON response object that contains all of the supported Apprise URLs. See [here for more details](https://github.com/caronc/apprise/wiki/Development_Apprise_Details#apprise-details)
| `/metrics` | GET | Prometheus endpoint for _basic_ Metrics Collection & Analysis and/or Observability.

As an example, the `/json/urls/{KEY}` response might return something like this:

Expand Down Expand Up @@ -784,3 +785,6 @@ The colon `:` prefix is the switch that starts the re-mapping rule engine. You
1. `:existing_key=`: By setting no value, the existing key is simply removed from the payload entirely
1. `:expected_key=A value to give it`: You can also fix an expected apprise key to a pre-generated string value.


## Metrics Collection & Analysis
Basic Prometheus support added through `/metrics` reference point.
8 changes: 8 additions & 0 deletions apprise_api/core/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@

# Apprise API
'api',

# Prometheus
'django_prometheus',
]

MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
'django.middleware.common.CommonMiddleware',
'core.middleware.theme.AutoThemeMiddleware',
'core.middleware.config.DetectConfigMiddleware',
'django_prometheus.middleware.PrometheusAfterMiddleware',
]

ROOT_URLCONF = 'core.urls'
Expand Down Expand Up @@ -129,6 +134,9 @@
APPRISE_DEFAULT_CONFIG_ID = \
os.environ.get('APPRISE_DEFAULT_CONFIG_ID', 'apprise')

# Define our Prometheus Namespace
PROMETHEUS_METRIC_NAMESPACE = "apprise"

# Static files relative path (CSS, JavaScript, Images)
STATIC_URL = BASE_URL + '/s/'

Expand Down
1 change: 1 addition & 0 deletions apprise_api/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@

urlpatterns = [
path('', include(api_urls)),
path('', include('django_prometheus.urls')),
]
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ requests
paho-mqtt < 2.0.0
gntp
cryptography

# prometheus metrics
django-prometheus

0 comments on commit 9147575

Please sign in to comment.