Skip to main content

monitapi is something to monitor API(URL) by a serverless.

Project description

monitapi

All Contributors

What is this

monitapi is something to monitor API(URL) by a serverless.
It supports hosting with FastAPI, running with CLI, and deploying to serverless.

Getting Started

Installation

monitapi is made by Python, so can you install it via PyPI.

pip install monitapi

Definition

The monitoring target and notification target can be defined using YAML.
It's defined as one file.

Monitoring target

monitor_targets:
    - {monitor-name}
      method: {http-method}
      url: {monitoring-url}
      headers:
          {header-name}: {header-value}
      status_code: {expected-status-code}
      timeout: {timeout}
  • monitor-name
    • Monitor name
  • http-method
    • HEAD, GET, POST, PUT, DELETE, OPTIONS, PATCH
  • monitoring-url
    • URL to monitor
  • header-name, header-value
    • HTTP headers
  • expected-status-code
    • The status code you expect from the monitored target.
  • timeout
    • Read timeout and connection timeout.

Notification target

notification_targets
    - {notification-name}
      type: {notification-type}
      endpoint: {notification-endpoint}
      payload:
          {request-payload}
  • notification-name
    • Notification name
  • notification-type
    • slack
  • notification-endpoint
    • The endpoint that sends the notification request.
  • request-payload
    • The POST payload to send to the endpoint.
    • You can use {{url}}, {{status_code}}, {{expected status_code}} and {{message}} as variables.

Example

monitor_targets:
    - github-monitapi
      method: "GET"
      url: https://github.com/fealone/monitapi
      status_code: 200
      timeout: 5

notification_targets:
    - notification-to-slack:
      type: slack
      endpoint: {Slack Incoming Webhooks endpoint}
      payload:
          blocks:
              -
                type: section
                text:
                    type: mrkdwn
                    text: "Target: {{url}}, Status: {{status_code}}, Expect: {{expected_status_code}}, Message: {{message}}"

Usage

One shot

monitapi monitor {targets.yaml}

Run with FastAPI

You need to put targets.yaml in the current directory.

monitapi serve

Deploy to serverless

monitapi deploy {platform} --name {function-name} --file {targets.yaml} --options {deploy-option}
  • platform
    • cloud_functions
  • function-name
    • Function name to deploy
  • targets.yaml
    • Definition file as YAML
  • deploy-option
    • Official deployment options

Example

monitapi deploy cloud_functions --name monitapi --file targets.yaml --options '{"--region": "asia-northeast1"}'

Contributors ✨

Thanks goes to these wonderful people (emoji key):


fealone

💻 🖋 🎨 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This project is licensed under the GPLv3 License - see the LICENSE file for details

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

monitapi-0.3.1.tar.gz (9.0 kB view hashes)

Uploaded Source

Built Distribution

monitapi-0.3.1-py3-none-any.whl (23.1 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