Skip to content
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

Fix/error catching get queues #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ The app needs sqs list and read access to the sqs policies

## Running

**You need to specify the region you to connect to**
Running on an ec2 machine using IAM roles:
`docker run -e AWS_REGION=<region> -d -p 9434:9434 ashiddo11/sqs-exporter`
To run the SQS exporter on Docker, you need to specify the region to connect to.

Or running it externally:
`docker run -d -p 9384:9384 -e AWS_ACCESS_KEY_ID=<access_key> -e AWS_SECRET_ACCESS_KEY=<secret_key> -e AWS_REGION=<region> ashiddo11/sqs-exporter`
When running on an ec2 machine using IAM role:

```
$ docker run -e AWS_REGION=<region> -d -p 9434:9434 ashiddo11/sqs-exporter
```

When running it externally:

```
$ docker run -d -p 9434:9434 -e AWS_ACCESS_KEY_ID=<access_key> -e AWS_SECRET_ACCESS_KEY=<secret_key> -e AWS_REGION=<region> ashiddo11/sqs-exporter
```
21 changes: 12 additions & 9 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ package collector

import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sqs"
"log"
"net/http"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sqs"
)

type MetricHandler struct{}

func (h MetricHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
queues,listQueueTags := getQueues()
queues, listQueueTags := getQueues()
for queue, attr := range queues {
msgAvailable := *attr.Attributes["ApproximateNumberOfMessages"]
msgDelayed := *attr.Attributes["ApproximateNumberOfMessagesDelayed"]
Expand Down Expand Up @@ -62,11 +63,13 @@ func getQueues() (queues map[string]*sqs.GetQueueAttributesOutput, tags map[stri
QueueUrl: aws.String(*urls),
}

resp, _ := client.GetQueueAttributes(params)
tagsResp, _ := client.ListQueueTags(tagsParams)
queueName := getQueueName(*urls)
queues[queueName] = resp
tags[queueName] = tagsResp
resp, _ := client.GetQueueAttributes(params)
tagsResp, err := client.ListQueueTags(tagsParams)
if err == nil {
queues[queueName] = resp
tags[queueName] = tagsResp
}
}
return queues,tags
return queues, tags
}