Skip to content

Commit

Permalink
Merge pull request #4 from chatwork/readme
Browse files Browse the repository at this point in the history
Add metrics description to README
  • Loading branch information
ada-u authored Nov 20, 2020
2 parents 2ea9af8 + a0f3a71 commit f3ede9e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# sendgrid-stats-exporter

## Overview

(TBW)

Prometheus exporter for SendGrid daily metrics exposed by SendGrid Stats API(v3).

+---------------------------+ +------------+ +--------------+
| SendGrid Stats API (v3) |---(collect /v3/stats)--->| exporter |<---(scrape /metrics)---| Prometheus |
Expand Down Expand Up @@ -50,26 +47,26 @@ Name | Description

Name | Description
---------|------------
blocks | dummy
bounce_drops | dummy
bounces | dummy
deferred | dummy
delivered | dummy
invalid_emails | dummy
processed | dummy
requests | dummy
spam_report_drops | dummy
spam_reports | dummy
unique_clicks | dummy
unique_opens | dummy
unsubscribe_drops | dummy
unsubscribes | dummy
blocks | The number of emails that were not allowed to be delivered by ISPs.
bounce_drops | The number of emails that were dropped because of a bounce.
bounces | The number of emails that bounced instead of being delivered.
deferred | The number of emails that temporarily could not be delivered.
delivered | The number of emails SendGrid was able to confirm were actually delivered to a recipient.
invalid_emails | The number of recipients who had malformed email addresses or whose mail provider reported the address as invalid.
processed | Requests from your website, application, or mail client via SMTP Relay or the API that SendGrid processed.
requests | The number of emails that were requested to be delivered.
spam_report_drops | The number of emails that were dropped due to a recipient previously marking your emails as spam.
spam_reports | The number of recipients who marked your email as spam.
unique_clicks | The number of unique recipients who clicked links in your emails.
unique_opens | The number of unique recipients who opened your emails.
unsubscribe_drops | The number of emails dropped due to a recipient unsubscribing from your emails.
unsubscribes | The number of recipients who unsubscribed from your emails.

### Running with Docker

(TBW)

- docker run
```
$ docker run -d -p 9154:9154 chatwork/sendgrid-stats-exporter
```

#### Running with `docker-compose`

Expand Down
11 changes: 8 additions & 3 deletions collect.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package main

import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log"
"time"
)

type Collector struct {
logger log.Logger

blocks *prometheus.Desc
bounceDrops *prometheus.Desc
bounces *prometheus.Desc
Expand All @@ -25,8 +28,10 @@ type Collector struct {
unsubscribes *prometheus.Desc
}

func collector() *Collector {
func collector(logger log.Logger) *Collector {
return &Collector{
logger: logger,

blocks: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "blocks"),
"blocks",
Expand Down Expand Up @@ -130,7 +135,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
today := time.Now()
statistics, err := collectByDate(today)
if err != nil {
log.Error(err)
level.Error(c.logger).Log(err)
return
}

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func main() {

level.Info(logger).Log("msg", "Listening on", *listenAddress)

collector := collector()
collector := collector(logger)
prometheus.MustRegister(collector)
prometheus.Unregister(prometheus.NewGoCollector())
registry := prometheus.NewRegistry()
Expand Down

0 comments on commit f3ede9e

Please sign in to comment.