SwingSight Metrics (app.py
) is a Flask-based application designed to capture and analyze metrics from golf shots. It uses metrics such as angle of departure, velocity at departure, and then projects the yardage and landing zone of golf balls.
Demo video on Youtube: Demo! Application metrics and Event-Driven Ansible
- Clone the repository:
git clone <repository-url>
- Install the required packages:
pip install flask requests
- Ensure that Datadog Agent is running on your machine.
To start the Flask application:
python <path-to-flask-app-file>
The application will start and listen on port 5050.
SwingSight Metrics integrates with Datadog through a custom check. The custom check fetches metrics from the Flask application and sends them to Datadog. This allows for monitoring and alerting based on the metrics generated by the application:
- swingsight.angle_of_departure: The angle at which the golf ball departs.
- swingsight.velocity_at_departure: The speed of the golf ball upon departure.
- swingsight.projected_yardage: Estimated distance the golf ball will travel.
- swingsight.projected_zone: Categorized zone based on projected yardage.
- swingsight.total_balls_hit: A count of the total number of balls hit.
- swingsight.count_zone_1: Count of balls that land in zone 1.
- swingsight.count_zone_2: Count of balls that land in zone 2.
- swingsight.count_zone_3: Count of balls that land in zone 3.
To set up the Datadog check:
- Place the
datadog/checks.d/swingsight_check
in thechecks.d
directory of the Datadog Agent. - Place
datadog/conf.d/swingsight_check.d
in the conf.d directory of the Datadog Agent. - Restart the Datadog Agent.
POST /golfball-hit
: Accepts a JSON payload withangle_of_departure
andvelocity_at_departure
to calculate and store the latest metrics.curl -X POST http://127.0.0.1:5050/golfball-hit -H "Content-Type: application/json" -d '{"angle_of_departure": 45, "velocity_at_departure": 41}'
GET /metrics
: Metrics as JSON. Used with Datadog check.GET /swingsight
: Displays the latest metrics on a dashboard.GET /clear-data
: Clears all stored metrics.