Skip to main content

DetectK HTTP Collector

HTTP/REST API collector for DetectK with support for various response formats and authentication methods.

Installation

pip install detectk-collectors-http

Features

  • Response Formats: JSON, plain text, CSV
  • Authentication: API key, Bearer token, Basic Auth, custom headers
  • Flexible Value Extraction: JSONPath, regex, direct value
  • Error Handling: Retry logic, timeout configuration
  • HTTP Methods: GET, POST
  • SSL Verification: Configurable

Usage

JSON API (JSONPath extraction)

name: "prometheus_metric"
description: "Collect metric from Prometheus API"

collector:
  type: "http"
  params:
    url: "http://prometheus:9090/api/v1/query"
    method: "GET"
    params:
      query: "up{job='api'}"
    response_format: "json"
    value_path: "data.result[0].value[1]"  # JSONPath
    timeout: 10

detector:
  type: "threshold"
  params:
    threshold: 0.5
    operator: "less_than"

Plain Text Response

collector:
  type: "http"
  params:
    url: "http://api.example.com/metrics/count"
    response_format: "text"
    # Response is direct numeric value

With Authentication

collector:
  type: "http"
  params:
    url: "https://api.example.com/metrics"
    headers:
      Authorization: "Bearer ${API_TOKEN}"
    response_format: "json"
    value_path: "metrics.active_users"

POST Request

collector:
  type: "http"
  params:
    url: "https://api.example.com/query"
    method: "POST"
    json:
      query: "SELECT COUNT(*) FROM events"
      time_range: "1h"
    headers:
      X-API-Key: "${API_KEY}"
    response_format: "json"
    value_path: "result.count"

Configuration

Required Parameters

  • url: API endpoint URL
  • response_format: Response format ("json", "text", "csv")
  • value_path: Path to extract value (for JSON/CSV)

Optional Parameters

  • method: HTTP method (default: "GET")
  • headers: Custom HTTP headers
  • params: Query parameters (GET)
  • json: JSON body (POST)
  • data: Form data (POST)
  • timeout: Request timeout in seconds (default: 30)
  • verify_ssl: Verify SSL certificates (default: True)
  • retry_count: Number of retries (default: 3)
  • retry_delay: Delay between retries in seconds (default: 1)

Authentication Examples

API Key (Header):

headers:
  X-API-Key: "${API_KEY}"

Bearer Token:

headers:
  Authorization: "Bearer ${TOKEN}"

Basic Auth:

headers:
  Authorization: "Basic ${BASE64_CREDENTIALS}"

JSONPath Syntax

Use dot notation and array indexing:

  • data.value - Simple path
  • data.result[0].value - Array indexing
  • metrics.active_users - Nested objects

Examples

See examples/http/ directory for complete configurations:

  • Prometheus query
  • Grafana API
  • Custom REST API
  • Health check endpoint

License

MIT

Metadata

Release files for detectk-collectors-http 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for detectk-collectors-http 0.1.1
File Size Uploaded
detectk_collectors_http-0.1.1.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for detectk-collectors-http 0.1.1
File Interpreter ABI Platform
detectk_collectors_http-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.4 kB

Release files / detectk_collectors_http-0.1.1.tar.gz

Download URL detectk_collectors_http-0.1.1.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f6ddab21a361dbb36268eb40b579e10543c63bfe6caadf9502c3a35ba1d209af
BLAKE2b-256 checksum
How to use checksums
fe140aebfbeb1313cf82ffa82f27189eb3f0299d536d8ff18ed5887ae1700738
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / detectk_collectors_http-0.1.1-py3-none-any.whl

Download URL detectk_collectors_http-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22c243abbec9726e2ae6572a582bb225192e125cd602bde0419916829c7e347f
BLAKE2b-256 checksum
How to use checksums
5d5ad56ed64a534c8c73f004f60ff3df5d711851ee72bc53291197bec04d7c28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page