diff --git a/cmd/aws_batch_exporter.go b/cmd/aws_batch_exporter.go index 6d3bbdb..c4248bd 100644 --- a/cmd/aws_batch_exporter.go +++ b/cmd/aws_batch_exporter.go @@ -1,9 +1,9 @@ package main import ( - "github.com/atr0phy/aws_batch_exporter" + awsBatchExporter "github.com/atr0phy/aws_batch_exporter" ) func main() { awsBatchExporter.Run() -} \ No newline at end of file +} diff --git a/collector.go b/collector.go index a913ab2..52805b6 100644 --- a/collector.go +++ b/collector.go @@ -14,14 +14,14 @@ import ( ) type Collector struct { - client batchiface.BatchAPI - region string + client batchiface.BatchAPI + region string timeout time.Duration } const ( namespace = "aws_batch" - timeout = 10 * time.Second + timeout = 10 * time.Second ) var ( @@ -69,7 +69,7 @@ var ( prometheus.BuildFQName(namespace, "", "failed_job"), "Job in the queue that are in the FAILED state", []string{"region", "id", "queue", "name"}, nil, - ) + ) jobSucceeded = prometheus.NewDesc( prometheus.BuildFQName(namespace, "", "succeeded_job"), @@ -79,20 +79,19 @@ var ( jobDescMap = map[string]*prometheus.Desc{ batch.JobStatusSubmitted: jobSubmitted, - batch.JobStatusPending: jobPending, - batch.JobStatusRunnable: jobRunnable, - batch.JobStatusStarting: jobStarting, - batch.JobStatusRunning: jobRunning, - batch.JobStatusFailed: jobFailed, + batch.JobStatusPending: jobPending, + batch.JobStatusRunnable: jobRunnable, + batch.JobStatusStarting: jobStarting, + batch.JobStatusRunning: jobRunning, + batch.JobStatusFailed: jobFailed, batch.JobStatusSucceeded: jobSucceeded, } - ) type JobResult struct { - id string - queue string - name string + id string + queue string + name string status string } @@ -103,8 +102,8 @@ func New(region string) (*Collector, error) { } return &Collector{ - client: batch.New(s), - region: "ap-northeast-1", + client: batch.New(s), + region: region, timeout: timeout, }, nil } @@ -134,7 +133,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) { defer wg.Done() var results []JobResult for _, s := range jobStatus { - r, err := c.client.ListJobsWithContext(ctx, &batch.ListJobsInput{JobQueue: d.JobQueueName,JobStatus: &s}) + r, err := c.client.ListJobsWithContext(ctx, &batch.ListJobsInput{JobQueue: d.JobQueueName, JobStatus: &s}) if err != nil { log.Printf("Error collecting job status metrics: %v\n", err) continue diff --git a/main.go b/main.go index e51f139..5bf1733 100644 --- a/main.go +++ b/main.go @@ -30,4 +30,4 @@ func Run() { prometheus.MustRegister(collector) http.Handle("/metrics", promhttp.Handler()) log.Fatal(http.ListenAndServe(addr, nil)) -} \ No newline at end of file +}