Created
October 27, 2017 08:12
-
-
Save ulope/a52ffd74eb03cbb46b680e40077624c2 to your computer and use it in GitHub Desktop.
prometheus backfill test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "2.1" | |
services: | |
prom: | |
image: prom/prometheus | |
volumes: | |
- ./prom.yml:/etc/prometheus/prometheus.yml | |
ports: | |
- 9090:9090 | |
source: | |
image: python:3.6 | |
volumes: | |
- .:/app | |
ports: | |
- 5000:5000 | |
command: bash -c 'pip install flask pendulum && python -u /app/main.py' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
from textwrap import dedent | |
import sys | |
from flask import Flask | |
import pendulum | |
app = Flask(__name__) | |
COUNTER = int((pendulum.now() - pendulum.Interval(hours=2)).timestamp()) | |
@app.route('/metrics') | |
def metrics(): | |
global COUNTER | |
COUNTER += 15 | |
now = int(pendulum.now().timestamp()) | |
print(COUNTER, now - COUNTER, file=sys.stderr) | |
if (now - COUNTER) <= 0: | |
return "" | |
return dedent(f"""\ | |
# HELP test_total Testmetric | |
# TYPE test_total gauge | |
test_total {randint(1, 50)} {COUNTER} | |
""") | |
if __name__ == '__main__': | |
app.run(debug=True, host="0.0.0.0") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global: | |
scrape_interval: 75ms | |
scrape_configs: | |
- job_name: 'test' | |
static_configs: | |
- targets: ['source:5000'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment