-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instrument plan/apply commands with Prometheus metrics
- Loading branch information
1 parent
e4dc33d
commit 944ff33
Showing
5 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"github.com/runatlantis/atlantis/server/logging" | ||
|
||
"net/http" | ||
) | ||
|
||
var ( | ||
OpsProcessedHistogram = promauto.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Name: "atlantis_ops_seconds", | ||
Help: "Histogram for plan/apply operations", | ||
Buckets: []float64{5, 10, 30, 60, 300, 600}, | ||
}, | ||
[]string{"repo", "directory", "workspace", "command", "success"}, | ||
) | ||
OpsInProgress = promauto.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "atlantis_ops_in_progress_total", | ||
Help: "The total number of in-progress plan/apply operations", | ||
}, | ||
[]string{"repository", "directory", "workspace", "operation"}, | ||
) | ||
) | ||
|
||
func Init(logger *logging.SimpleLogger) { | ||
http.Handle("/metrics", promhttp.Handler()) | ||
go func() { | ||
logger.Info("Metrics server started - listening on port 2122") | ||
http.ListenAndServe(":2112", nil) | ||
}() | ||
} |