Skip to content

Commit f3ede9e

Browse files
authored
Merge pull request #4 from chatwork/readme
Add metrics description to README
2 parents 2ea9af8 + a0f3a71 commit f3ede9e

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# sendgrid-stats-exporter
22

3-
## Overview
4-
5-
(TBW)
6-
3+
Prometheus exporter for SendGrid daily metrics exposed by SendGrid Stats API(v3).
74

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

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

6865
### Running with Docker
6966

70-
(TBW)
71-
72-
- docker run
67+
```
68+
$ docker run -d -p 9154:9154 chatwork/sendgrid-stats-exporter
69+
```
7370

7471
#### Running with `docker-compose`
7572

collect.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package main
22

33
import (
4+
"github.com/go-kit/kit/log"
5+
"github.com/go-kit/kit/log/level"
46
"github.com/prometheus/client_golang/prometheus"
5-
"github.com/prometheus/common/log"
67
"time"
78
)
89

910
type Collector struct {
11+
logger log.Logger
12+
1013
blocks *prometheus.Desc
1114
bounceDrops *prometheus.Desc
1215
bounces *prometheus.Desc
@@ -25,8 +28,10 @@ type Collector struct {
2528
unsubscribes *prometheus.Desc
2629
}
2730

28-
func collector() *Collector {
31+
func collector(logger log.Logger) *Collector {
2932
return &Collector{
33+
logger: logger,
34+
3035
blocks: prometheus.NewDesc(
3136
prometheus.BuildFQName(namespace, "", "blocks"),
3237
"blocks",
@@ -130,7 +135,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) {
130135
today := time.Now()
131136
statistics, err := collectByDate(today)
132137
if err != nil {
133-
log.Error(err)
138+
level.Error(c.logger).Log(err)
134139
return
135140
}
136141

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func main() {
5959

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

62-
collector := collector()
62+
collector := collector(logger)
6363
prometheus.MustRegister(collector)
6464
prometheus.Unregister(prometheus.NewGoCollector())
6565
registry := prometheus.NewRegistry()

0 commit comments

Comments
 (0)