Skip to content
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Run `prometheus-ecs-discovery --help` to get information.

The command line parameters that can be used are:

* -config.cluster (string): the name of a cluster to scrape (defaults to scraping all clusters)
* -config.cluster (string): the list name of a cluster with seperator(,) to scrape (defaults to scraping all clusters)
* ex : -config.cluster=a-cluster,b-cluster”
* -config.scrape-interval (duration): interval at which to scrape
the AWS API for ECS service discovery information (default 1m0s)
* -config.scrape-times (int): how many times to scrape before
Expand Down
48 changes: 25 additions & 23 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var times = flag.Int("config.scrape-times", 0, "how many times to scrape before
var roleArn = flag.String("config.role-arn", "", "ARN of the role to assume when scraping the AWS API (optional)")
var prometheusPortLabel = flag.String("config.port-label", "PROMETHEUS_EXPORTER_PORT", "Docker label to define the scrape port of the application (if missing an application won't be scraped)")
var prometheusPathLabel = flag.String("config.path-label", "PROMETHEUS_EXPORTER_PATH", "Docker label to define the scrape path of the application")
var prometheusSchemeLabel= flag.String("config.scheme-label", "PROMETHEUS_EXPORTER_SCHEME", "Docker label to define the scheme of the target application")
var prometheusSchemeLabel = flag.String("config.scheme-label", "PROMETHEUS_EXPORTER_SCHEME", "Docker label to define the scheme of the target application")
var prometheusFilterLabel = flag.String("config.filter-label", "", "Docker label (and optionally value) to require to scrape the application")
var prometheusServerNameLabel = flag.String("config.server-name-label", "PROMETHEUS_EXPORTER_SERVER_NAME", "Docker label to define the server name")
var prometheusJobNameLabel = flag.String("config.job-name-label", "PROMETHEUS_EXPORTER_JOB_NAME", "Docker label to define the job name")
Expand Down Expand Up @@ -131,25 +131,26 @@ type PrometheusTaskInfo struct {
// container in the task has a PROMETHEUS_EXPORTER_PORT
//
// Example:
// ...
// "Name": "apache",
// "DockerLabels": {
// "PROMETHEUS_EXPORTER_PORT": "1234"
// },
// ...
// "PortMappings": [
// {
// "ContainerPort": 1883,
// "HostPort": 0,
// "Protocol": "tcp"
// },
// {
// "ContainerPort": 1234,
// "HostPort": 0,
// "Protocol": "tcp"
// }
// ],
// ...
//
// ...
// "Name": "apache",
// "DockerLabels": {
// "PROMETHEUS_EXPORTER_PORT": "1234"
// },
// ...
// "PortMappings": [
// {
// "ContainerPort": 1883,
// "HostPort": 0,
// "Protocol": "tcp"
// },
// {
// "ContainerPort": 1234,
// "HostPort": 0,
// "Protocol": "tcp"
// }
// ],
// ...
func (t *AugmentedTask) ExporterInformation() []*PrometheusTaskInfo {
ret := []*PrometheusTaskInfo{}
var host string
Expand Down Expand Up @@ -297,7 +298,7 @@ func (t *AugmentedTask) ExporterInformation() []*PrometheusTaskInfo {

scheme, ok = d.DockerLabels[*prometheusSchemeLabel]
if ok {
labels.Scheme = scheme
labels.Scheme = scheme
}

ret = append(ret, &PrometheusTaskInfo{
Expand Down Expand Up @@ -624,8 +625,9 @@ func main() {
var clusters *ecs.ListClustersOutput

if *cluster != "" {
clusterArray := strings.Split(*cluster, ",")
res, err := svc.DescribeClusters(context.Background(), &ecs.DescribeClustersInput{
Clusters: []string{*cluster},
Clusters: clusterArray,
})
if err != nil {
logError(err)
Expand All @@ -638,7 +640,7 @@ func main() {
}

clusters = &ecs.ListClustersOutput{
ClusterArns: []string{*cluster},
ClusterArns: clusterArray,
}
} else {
c, err := GetClusters(svc)
Expand Down