• Stars
    star
    224
  • Rank 177,792 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Prometheus pagespeed exporter

Prometheus Exporter for Google Pagespeed Online Metrics

Travis CI

Examples

To start the example with the default dashboard (docker-compose required)

$ git clone [email protected]:foomo/pagespeed_exporter.git
$ cd pagespeed_exporter/example
$ docker-compose up -d

After that, the application should be running on localhost:3000 with username admin and password s3cr3t.

The provided dashboard (Pagespeed) will be loaded with data after the first scrape.

Dashboard

The dashboard can be found at grafana

Note: The example dashboard assumes you're fetching all pagespeed categories.

Understanding Metrics

Prometheus exporter for google pagespeed metrics

Building And Running

Building

$ make

Examples

To run pagespeed exporter we need to obtain the google api key for the pagespeed. Instructions how to create a key for pagespeed can be found here

pagespeed_exporter <arguments>

$ pagespeed_exporter -api-key {KEY} -targets https://google.com,https://prometheus.io -listener :80

Exporter Target Specification

Targets can be configured in either plaintext

https://github.com/foomo/pagespeed_exporter
https://mysite.com/test?test=true

Or via JSON which adds additional parameters

// URL can't be invalid
// Strategy can only be mobile/desktop
// If strategy is not specified, both desktop & mobile will be used
// Categories can be any of accessibility/best-practices/performance/pwa/seo
// If categories are not specified, all categories will be used
// Parameters are passed down to google pagespeed api

{"url":"https://github.com/foomo/pagespeed_exporter","campaign":"test","locale":"en","source":"source"}

{"url":"https://mysite.com/test?test=true","strategy":"mobile"}

{"url":"https://mysite.com/test?test=true","categories": ["best-practices"]}

Configuration specification in JSON and plain is supported both in command line & prometheus configuration

Exporter configuration

Configuration of targets can be done via docker and via prometheus

Flag Variable Description Default Required
-api-key PAGESPEED_API_KEY sets the google API key used for pagespeed False
-targets PAGESPEED_TARGETS comma separated list of targets to measure False
-categories PAGESPEED_CATEGORIES comma separated list of categories to check accessibility,best-practices,performance,pwa,seo False
-t NONE multi-value target array (check docker comp) False
-listener PAGESPEED_LISTENER sets the listener address for the exporters :9271 False
-parallel PAGESPEED_PARALLEL sets the execution of targets to be parallel false False
-pushGatewayUrl PUSHGATEWAY_URL sets the pushgateway url to send the metrics False
-pushGatewayJob PUSHGATEWAY_JOB sets the pushgateway job name pagespeed_exporter False

Note: google api key is required only if scraping more than 2 targets/second

Note: exporter can be run without targets, and later targets provided via prometheus

Pushing metrics via push gateway

If you don't want to change the prometheus scrape_configs, you can send the metrics using push gateway using a batch job. Just configure the pushgateway url and use the /probe endpoint with query parameter target and the metrics will be send to prometheus.

curl http://localhost:9271/probe?target=https://www.example.com

Exporter Target Configuration (VIA PROMETHEUS)

Example configuration with simple and complex values

(Examples can ve found in the example folder)

  - job_name: pagespeed_exporter_probe
      metrics_path: /probe
      # Re-Label configurations so that we can use them
      # to configure the pagespeed exporter
      relabel_configs:
        - source_labels: [__address__]
          target_label: __param_target
        - source_labels: [__param_target]
          target_label: instance
        - target_label: __address__
          replacement: "pagespeed_exporter:9271"
      static_configs:
        - targets:
            - 'https://example.com/' # Example PLAIN
            - '{"url":"https://example.com/","campaign":"test","locale":"en","source":"source"}'  
            - '{"url":"https://example.com/mobileonly","strategy":"mobile"}'                    

Docker

$ docker run -p "9271:9271" --rm foomo/pagespeed_exporter -api-key {KEY} -t https://google.com,https://prometheus.io

or

$ docker run -p "9271:9271" --rm \
    --env PAGESPEED_API_KEY={KEY} \
    --env PAGESPEED_TARGETS=https://google.com,https://prometheus.io \
    --env PAGESPEED_CATEGORIES=accessibility,pwa \
    foomo/pagespeed_exporter

Prometheus & Docker Compose

Check out the docker-compose folder

Kubernetes/Helm

You can install the included Helm chart to your k8s cluster with:

$ helm install helm/pagespeed-exporter

And then, to quickly test it:

$ kubectl get pods
pagespeed-exporter-riotous-dragonfly-6b99955999-hj2kw   1/1     Running   0          1m

$ kubectl exec -ti pagespeed-exporter-riotous-dragonfly-6b99955999-hj2kw -- sh
# apk add curl
# curl localhost:9271/metrics
pagespeed_lighthouse_audit_score{audit="first-contentful-paint",host="https://www.google.com",path="/",strategy="mobile"} 1
pagespeed_lighthouse_audit_score{audit="first-contentful-paint",host="https://www.google.com",path="/webhp",strategy="desktop"} 1
pagespeed_lighthouse_audit_score{audit="first-contentful-paint",host="https://www.google.com",path="/webhp",strategy="mobile"} 1
...

More Repositories

1

simplecert

golang autocert library for letsencrypt
Go
202
star
2

htpasswd

golang htpasswd utilities
Go
39
star
3

tlssocks

secure socks5 over tls / tcp
Go
26
star
4

gotsrpc

Go TypeScript RPC - expose Go code over http JSON RPC to TypeScript clients, oh and gorpc is much easier with this too
Go
25
star
5

soap

SOAP is dead, long live SOAP
Go
23
star
6

shop

generic ecommerce core framework
Go
19
star
7

gocontentful

An Contentful Entry-Reference Mapper for Go
Go
9
star
8

keel

Opinionated k8s service framework.
Go
8
star
9

contentserver

Serves content tree structures very quickly through a json socket api
Go
8
star
10

petze

monitor web services and report, if they are not working
Go
5
star
11

logfrog

cli program, that likes json logs and it helps you to like them too
Go
4
star
12

squadron

K8s Deployment Manager App
Go
4
star
13

config-bob

build configs. mixin secrets.
Go
3
star
14

crontinuous

Crontinuous is a time-based job scheduler for docker.
Go
2
star
15

Foomo.TestRunner

Foomo phpUnit module
PHP
2
star
16

Foomo.Services

Foomo services module
PHP
2
star
17

Sandbox

Foomo sandbox project to get your hands dirty fast
PHP
2
star
18

Foomo.Docs

Foomo docs module
PHP
2
star
19

Foomo.Theme

Foomo theme module
PHP
2
star
20

Foomo.Zugspitze

Foomo Zugspitze flash / flex client framework integration module
PHP
2
star
21

Foomo.Doctrine2

Foomo doctrine2 module
PHP
2
star
22

Foomo

Foomo core module
PHP
2
star
23

Foomo.Flash

Foomo flash module
PHP
2
star
24

walker

walks websites
Go
2
star
25

neosproxy

A NEOS proxy with support for the Foomo.Neos.Contentserver package
Go
2
star
26

fender

Opinionated validation library.
Go
2
star
27

ownbrew

Your local project package manager
Go
1
star
28

Foomo.ContentServer

php client for the go content server
PHP
1
star
29

go

Go standard library extension, adding the missing parts used in the foomo ecosystem to keep dry.
Go
1
star
30

Foomo.ElasticSearch

PHP
1
star
31

ASLibrary-foomo_mx

ActionScript
1
star
32

nodeflock

run node processes and talk to them
Go
1
star
33

FlexProject-zugspitze_as3Examples

ActionScript
1
star
34

ASLibrary-zugspitze_core

ActionScript
1
star
35

ASLibrary-zugspitze_as3

ActionScript
1
star
36

tlsconfig

tls configuration utilities
Go
1
star
37

FlexProject-foomo_examples_todo

Client application for Foomo.Todo
ActionScript
1
star
38

contentfulcommander

A toolbox of non-trivial Contentful interactions
Go
1
star
39

gograpple

go grapple that go program ...
Go
1
star
40

ASLibrary-foomo_spark

Common spark library
ActionScript
1
star
41

FlexProject-zugspitze_mxExamples

ActionScript
1
star
42

Foomo.Wordpress

Wordpress integration module
PHP
1
star
43

ASLibrary-foomo_air

Common air library
ActionScript
1
star
44

dumpster

dump project data and restore them
Go
1
star
45

foomo-releaser

Go
1
star
46

FlexProject-zugspitze_services_uploadExamples

ActionScript
1
star
47

ASLibrary-zugspitze_services_logger

Service and utility classes for client logging
ActionScript
1
star
48

ASLibrary-zugspitze_mx

ActionScript
1
star
49

ASLibrary-zugspitze_mobile

ActionScript
1
star
50

ASLibrary-foomo_as3

Common as3 library
ActionScript
1
star
51

ssiege

http benchmarking and load testing utility with session support
Go
1
star
52

ASLibrary-foomo_rpc

ActionScript
1
star
53

ASLibrary-foomo_core

ActionScript
1
star
54

FlexProject-zugspitze_mobileExamples

ActionScript
1
star
55

terradays

Terraform utility, cause even the good ones need a couple of days to create a planet
Go
1
star
56

ASLibrary-zugspitze_spark

ActionScript
1
star
57

ASLibrary-zugspitze_rpc

ActionScript
1
star
58

FlexProject-zugspitze_sparkExamples

ActionScript
1
star
59

sesamy-cli

Server Side Tag Management System CLI
Go
1
star
60

ASLibrary-zugspitze_air_spark

ActionScript
1
star
61

FlexProject-zugspitze_air_sparkExamples

ActionScript
1
star
62

Foomo.Examples

Example module
PHP
1
star
63

variant-balancer

web load balancer with support for variants
Go
1
star
64

webgrapple

a proxy to take over routes of a remote server with local web servers
Go
1
star
65

FlexProject-zugspitze_services_loggerExamples

Logger serivce examples
ActionScript
1
star
66

ASLibrary-zugspitze_services_upload

ActionScript
1
star
67

posh

Project Oriented SHELL
Go
1
star
68

foomo-docs

docs for the bestbytes foomo stack
MDX
1
star
69

posh-providers

Project Oriented SHELL (posh) Providers
Go
1
star
70

ASLibrary-zugspitze_air_mx

ActionScript
1
star