Skip to content

Update the Primery Key for Quay in the Database #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions grafana/dashboard/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"targets": [
{
"datasource": "MySQL",
"rawSql": "SELECT DATE(datetime) AS date, kind, SUM(count) AS total_count FROM aggregated_logs GROUP BY date, kind ORDER BY date ASC;",
"rawSql": "SELECT DATE(datetime) AS date, SUM(count) AS total_count FROM aggregated_logs GROUP BY date ORDER BY date ASC;",
"format": "time_series"
}
],
Expand All @@ -34,7 +34,7 @@
"targets": [
{
"datasource": "MySQL",
"rawSql": "SELECT DATE_FORMAT(datetime, '%Y-%m') AS month, kind, SUM(count) AS total_count FROM aggregated_logsGROUP BY month, kind ORDER BY month ASC;",
"rawSql": "SELECT DATE_FORMAT(datetime, '%Y-%m') AS month, SUM(count) AS total_count FROM aggregated_logs GROUP BY month ORDER BY month ASC;",
"format": "time_series"
}
],
Expand All @@ -53,6 +53,56 @@
}
}
},
{
"title": "Quay Pull Events by Day and Kind",
"type": "timeseries",
"targets": [
{
"datasource": "MySQL",
"rawSql": "SELECT DATE(datetime) AS day, kind, SUM(count) AS total_count FROM aggregated_logs GROUP BY day, kind ORDER BY day, kind;",
"format": "time_series"
}
],
"options": {
"tooltip": {
"mode": "all",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"custom": {
"lineWidth": 2,
"fillOpacity": 50
}
}
}
},
{
"title": "Quay Pull Events by Month and Kind",
"type": "timeseries",
"targets": [
{
"datasource": "MySQL",
"rawSql": "SELECT DATE_FORMAT(datetime, '%Y-%m') AS month, kind, SUM(count) AS total_count FROM aggregated_logs GROUP BY month, kind ORDER BY month, kind;",
"format": "time_series"
}
],
"options": {
"tooltip": {
"mode": "all",
"sort": "desc"
}
},
"fieldConfig": {
"defaults": {
"custom": {
"lineWidth": 2,
"fillOpacity": 50
}
}
}
},
{
"title": "DCI Test Runs Over Time",
"type": "timeseries",
Expand Down
6 changes: 2 additions & 4 deletions pkg/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ func insertComponentData(db *sql.DB, jobID, commit, createdAt string, totalSucce
func insertQuayData(db *sql.DB, datetime string, count int, kind string) error {
insertQuery := `
INSERT INTO aggregated_logs (datetime, count, kind)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE
count = VALUES(count);
VALUES (?, ?, ?);
`
_, err := db.Exec(insertQuery, datetime, count, kind)
return err
Expand Down Expand Up @@ -68,7 +66,7 @@ func createTables(db *sql.DB) error {
datetime DATETIME NOT NULL,
count INT NOT NULL,
kind VARCHAR(255) NOT NULL,
PRIMARY KEY datetime
PRIMARY KEY (datetime, kind)
);`,
`CREATE TABLE IF NOT EXISTS dci_components (
job_id VARCHAR(36) PRIMARY KEY,
Expand Down