Below is an updated README file that reflects all the changes and improvements made to your FastAPI Telex integration.
This FastAPI application logs the health status of a remote MySQL server and sends the results to a Telex channel via a user-configured webhook. The integration is designed to be installed on the Telex platform and is configured via a JSON file served at /integration.json
.
-
MySQL Health Check: Connects to a remote MySQL server and retrieves key metrics including:
- MySQL version
- Database name
- Uptime
- Slow queries
- Threads connected
- Total connections
- Current open connections
- Query cache hits
- Available tables in the database
-
Telex Integration: Sends the formatted health status message to a Telex channel using a webhook URL provided by the user.
-
User-Supplied Configuration: All sensitive details (MySQL host, user, password, database, and Telex webhook URL) are provided by the user during integration setup via the integration payload. No sensitive information is hardcoded or taken from environment variables.
-
Interval Configuration: The integration supports running on an interval (default set to every 5 minutes, using the cron expression
*/5 * * * *
). -
Non-blocking Background Processing: The health check is executed in a background task, allowing the
/tick
endpoint to return immediately with the MySQL status.
Returns the integration configuration used by Telex to set up the application. The JSON configuration includes:
- Metadata (app name, description, logo, website, etc.)
- Required settings for MySQL connection and Telex webhook configuration
- The tick URL that Telex will use to trigger the integration
Example JSON (partial):
{
"data": {
"date": {
"created_at": "2025-02-18",
"updated_at": "2025-02-18"
},
"descriptions": {
"app_name": "MySQL Performance Monitor",
"app_description": "Monitors MySQL Databases in real time",
"app_logo": "https://i.imgur.com/lZqvffp.png",
"app_url": "https://your-deployed-url",
"background_color": "#fff"
},
"is_active": "true",
"integration_category": "Monitoring & Logging",
"integration_type": "interval",
"key_features": [
"Monitors a remote MySQL server",
"Logs MySQL Server health status to the Telex channel"
],
"author": "Dohou Daniel Favour",
"settings": [
{
"label": "MySQL Host",
"type": "text",
"required": "true",
"default": ""
},
{
"label": "MySQL User",
"type": "text",
"required": "true",
"default": ""
},
{
"label": "MySQL Password",
"type": "text",
"required": "true",
"default": ""
},
{
"label": "MySQL Database",
"type": "text",
"required": "true",
"default": ""
},
{
"label": "WebHook URL Configuration",
"type": "text",
"required": "true",
"default": ""
},
{
"label": "interval",
"type": "text",
"required": "true",
"default": "*/5 * * * *"
}
],
"target_url": "https://your-deployed-url/tick",
"tick_url": "https://your-deployed-url/tick"
}
}
Triggers the MySQL health check:
- Accepts both GET and POST requests.
- When triggered, the endpoint schedules a background task that:
- Uses the user-provided MySQL details to check the server status.
- Sends the health status message to the Telex channel using the provided webhook URL.
- Also returns a JSON response containing the MySQL status and the message
"Check your Telex channel"
.
-
Clone the Repository:
git clone https://github.com/telexintegrations/mysql-performance-monitor cd mysql-performance-monitor
-
Create and Activate a Virtual Environment:
python3 -m venv .venv source .venv/bin/activate # Windows: .venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
Ensure that the following packages are included in your
requirements.txt
:- fastapi
- uvicorn
- httpx
- pymysql
- python-dotenv
-
Deploy the Application:
You can run the application locally for testing:
uvicorn app:app --host 0.0.0.0 --port 5000
When deploying on a platform like Render, ensure you bind to
0.0.0.0
and use the platform's provided$PORT
environment variable.
To test the integration, use the following curl
command to trigger the /tick
endpoint with user-supplied details:
curl --location --request POST 'http://mysql-performance-monitor.onrender.com/tick' --header 'Content-Type: application/json' --data '{
"channel_id": "mysql-performance-monitor",
"return_url": "Enter Your Desired Channel's WebHook URL here",
"settings": [
{
"label": "MySQL Host",
"type": "text",
"required": true,
"default": "Enter Your Server's IP Address Here"
},
{
"label": "MySQL User",
"type": "text",
"required": true,
"default": "Enter Your MySQL User Here"
},
{
"label": "MySQL Password",
"type": "text",
"required": true,
"default": "Enter Your MySQL Password Here"
},
{
"label": "MySQL Database",
"type": "text",
"required": true,
"default": "Enter Your MySQL Database Here"
},
{
"label": "WebHook URL Configuration",
"type": "text",
"required": true,
"default": "Enter Your Desired Channel's WebHook URL here"
},
{
"label": "interval",
"type": "text",
"required": true,
"default": "*/5 * * * *"
}
]
}'
This command sends a JSON payload with your MySQL connection details and the Telex webhook URL. The /tick
endpoint will then trigger the health check, send the results to your Telex channel, and return a response indicating that the status was sent.