Sign inSign up

hatamiarash7/iranleague-exporter

By hatamiarash7

•Updated 10 months ago

Image
0

7.5K

hatamiarash7/iranleague-exporter repository overview

⁠Iran Football League Exporter

made-with-python GitHub release Release GitHub License

Export football match schedules as Prometheus metrics for Iran league. This script will use the https://iranleague.ir⁠ site to fetch the match schedules and export them as Prometheus metrics.

⁠Features

  • Automatic retry with exponential backoff for failed requests
  • Prometheus metrics for match schedules with basic authentication
  • Health check and readiness endpoints (/health, /ready)

⁠How-To

You can run this exporter as a Docker container:

docker run -d -p 8000:8000 \
  -e AUTH_USERNAME=admin \
  -e AUTH_PASSWORD=1234 \
  hatamiarash7/iranleague-exporter:latest

Check the metrics at http://localhost:8000/metrics.

⁠Endpoints
EndpointAuth RequiredDescription
/metricsYesPrometheus metrics
/healthNoHealth check (liveness probe)
/readyNoReadiness check (readiness probe)

⁠Configuration

You can configure the exporter using the following environment variables:

⁠Server Configuration
KeyDefaultDescription
HTTP_HOST0.0.0.0Host to bind the HTTP server to
HTTP_PORT8000Port to bind the HTTP server to
HTTP_WORKERS1Number of worker processes
LOG_LEVELINFOLog level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
⁠Authentication
KeyDefaultDescription
AUTH_USERNAMEUsername for basic authentication
AUTH_PASSWORDPassword for basic authentication
⁠Crawler Configuration
KeyDefaultDescription
CRAWLER_URLhttps://iranleague.ir/fa/MatchSchedule/1/1⁠URL to fetch match schedules from
CRAWLER_CONNECT_TIMEOUT5.0Connection timeout in seconds
CRAWLER_READ_TIMEOUT10.0Read timeout in seconds
CRAWLER_MAX_RETRIES3Maximum number of retry attempts
CRAWLER_RETRY_BACKOFF0.5Backoff factor for retries
CRAWLER_USER_AGENTIranLeagueExporter/1.0User-Agent header for requests
⁠Other Settings
KeyDefaultDescription
LABEL_LANGENLanguage for the team names (FA, EN)
UPDATE_INTERVAL30Interval to update the match schedules (in minutes)
TZTimezone (e.g., Asia/Tehran)

⁠Prometheus Metrics

The exporter provides the following metrics:

MetricTypeDescription
ir_league_matchesGaugeTimestamp of upcoming matches
ir_league_matches_totalGaugeTotal number of future matches found
ir_league_scrape_duration_secondsGaugeDuration of the last scrape in seconds
ir_league_scrape_successGaugeWhether the last scrape was successful
ir_league_exporter_infoInfoExporter version and configuration info

⁠Development

⁠Prerequisites
  • Python 3.10+
  • Poetry
⁠Setup
# Install dependencies
make install

# Run locally
make run

# Run tests
make test

# Run tests with coverage
make test-cov

# Lint code
make lint

# Format code
make format

# Type check
make typecheck

⁠Support 💛

Donate with Bitcoin Donate with Ethereum

⁠Contributing 🤝

Don't be shy and reach out to us if you want to contribute 😉

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

⁠Issues

Each project may have many problems. Contributing to the better development of this project by reporting them. 👍

Tag summary

Content type

Image

Digest

sha256:68d018407…

Size

182.7 MB

Last updated

10 months ago

docker pull hatamiarash7/iranleague-exporter