{"id":13582445,"url":"https://github.com/foomo/pagespeed_exporter","last_synced_at":"2025-05-16T06:07:26.894Z","repository":{"id":22297564,"uuid":"95006251","full_name":"foomo/pagespeed_exporter","owner":"foomo","description":"Prometheus pagespeed exporter","archived":false,"fork":false,"pushed_at":"2025-03-13T01:24:48.000Z","size":542,"stargazers_count":244,"open_issues_count":4,"forks_count":33,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-04-12T04:44:44.172Z","etag":null,"topics":["docker","golang","google-pagespeed-metrics","lighthouse","metrics","pagespeed","pagespeed-exporter","prometheus","prometheus-exporter","speedtest"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foomo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-21T13:20:03.000Z","updated_at":"2025-04-04T18:32:56.000Z","dependencies_parsed_at":"2024-05-10T14:42:00.440Z","dependency_job_id":"4397f458-c1ef-4752-9a7d-4373f5afa64a","html_url":"https://github.com/foomo/pagespeed_exporter","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foomo%2Fpagespeed_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foomo%2Fpagespeed_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foomo%2Fpagespeed_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foomo%2Fpagespeed_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foomo","download_url":"https://codeload.github.com/foomo/pagespeed_exporter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478190,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","golang","google-pagespeed-metrics","lighthouse","metrics","pagespeed","pagespeed-exporter","prometheus","prometheus-exporter","speedtest"],"created_at":"2024-08-01T15:02:43.316Z","updated_at":"2025-05-16T06:07:21.884Z","avatar_url":"https://github.com/foomo.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Prometheus Exporter for Google Pagespeed Online Metrics\n[![Travis CI](https://travis-ci.org/foomo/pagespeed_exporter.svg?branch=master)](https://travis-ci.org/foomo/pagespeed_exporter)\n\n\n## Examples\n\nTo start the example with the default dashboard (docker-compose required)\n\n```\n$ git clone git@github.com:foomo/pagespeed_exporter.git\n$ cd pagespeed_exporter/example\n$ docker-compose up -d\n```\n\nAfter that, the application should be running on ``localhost:3000`` with username admin and password s3cr3t.\n\nThe provided dashboard (Pagespeed) will be loaded with data after the first scrape.\n\n![Dashboard](https://github.com/foomo/pagespeed_exporter/raw/assets/dashboard.png?raw=true)\n\nThe  dashboard can be found at [grafana](https://grafana.com/grafana/dashboards/9510-pagespeed/)\n\nNote: The example dashboard assumes you're fetching all pagespeed categories.\n\n## Understanding Metrics\n\n* https://github.com/GoogleChrome/lighthouse/blob/master/docs/understanding-results.md\n* https://developers.google.com/speed/docs/insights/v5/reference/pagespeedapi/runpagespeed\n\nPrometheus exporter for google pagespeed metrics\n\n\n## Building And Running\n\n### Building\n\n```sh\n$ make\n```\n\n### Examples\n\nTo run pagespeed exporter we need to obtain the google api key for the pagespeed. \nInstructions how to create a key for pagespeed can be found [here](https://developers.google.com/speed/docs/insights/v2/first-app)\n\n`pagespeed_exporter \u003carguments\u003e`\n\n```sh\n$ pagespeed_exporter -api-key {KEY} -targets https://google.com,https://prometheus.io -listener :80\n```\n\n### Exporter Target Specification\n\nTargets can be configured in either plaintext \n\n```\nhttps://github.com/foomo/pagespeed_exporter\nhttps://mysite.com/test?test=true\n```\n\nOr via JSON which adds additional parameters\n\n```\n// URL can't be invalid\n// Strategy can only be mobile/desktop\n// If strategy is not specified, both desktop \u0026 mobile will be used\n// Categories can be any of accessibility/best-practices/performance/pwa/seo\n// If categories are not specified, all categories will be used\n// Parameters are passed down to google pagespeed api\n\n{\"url\":\"https://github.com/foomo/pagespeed_exporter\",\"campaign\":\"test\",\"locale\":\"en\",\"source\":\"source\"}\n\n{\"url\":\"https://mysite.com/test?test=true\",\"strategy\":\"mobile\"}\n\n{\"url\":\"https://mysite.com/test?test=true\",\"categories\": [\"best-practices\"]}\n\n```\n\nConfiguration specification in JSON and plain is supported both in command line \u0026 prometheus configuration \n\n### Exporter configuration \n\nConfiguration of targets can be done via docker and via prometheus\n\n| Flag             | Variable             | Description                                   | Default                                          | Required |\n|------------------|----------------------|-----------------------------------------------|--------------------------------------------------|----------|\n| -api-key         | PAGESPEED_API_KEY    | sets the google API key used for pagespeed    |                                                  | False    |\n| -targets         | PAGESPEED_TARGETS    | comma separated list of targets to measure    |                                                  | False    |\n| -categories      | PAGESPEED_CATEGORIES | comma separated list of categories to check   | accessibility,best-practices,performance,pwa,seo | False    |\n| -t               | NONE                 | multi-value target array (check docker comp)  |                                                  | False    |\n| -listener        | PAGESPEED_LISTENER   | sets the listener address for the exporters   | :9271                                            | False    |\n| -parallel        | PAGESPEED_PARALLEL   | sets the execution of targets to be parallel  | false                                            | False    |\n| -pushGatewayUrl  | PUSHGATEWAY_URL      | sets the pushgateway url to send the metrics  |                                                  | False    |\n| -pushGatewayJob  | PUSHGATEWAY_JOB      | sets the pushgateway job name                 | pagespeed_exporter                               | False    |\n\nNote: google api key is required only if scraping more than 2 targets/second\n\nNote: exporter can be run without targets, and later targets provided via prometheus\n\n\n### Pushing metrics via push gateway\n\nIf you don't want to change the prometheus `scrape_configs`, you can send the metrics using push gateway using a batch job.\nJust configure the pushgateway url and use the `/probe` endpoint with query parameter `target` and the metrics will be send to prometheus.\n\n`curl http://localhost:9271/probe?target=https://www.example.com`\n\n\n### Exporter Target Configuration (VIA PROMETHEUS)\n\nExample configuration with simple and complex values\n\n(Examples can ve found in the example folder)\n\n```yaml\n\n  - job_name: pagespeed_exporter_probe\n      metrics_path: /probe\n      # Re-Label configurations so that we can use them\n      # to configure the pagespeed exporter\n      relabel_configs:\n        - source_labels: [__address__]\n          target_label: __param_target\n        - source_labels: [__param_target]\n          target_label: instance\n        - target_label: __address__\n          replacement: \"pagespeed_exporter:9271\"\n      static_configs:\n        - targets:\n            - 'https://example.com/' # Example PLAIN\n            - '{\"url\":\"https://example.com/\",\"campaign\":\"test\",\"locale\":\"en\",\"source\":\"source\"}'  \n            - '{\"url\":\"https://example.com/mobileonly\",\"strategy\":\"mobile\"}'                    \n\n```\n\n\n### Docker\n\n```sh\n$ docker run -p \"9271:9271\" --rm foomo/pagespeed_exporter -api-key {KEY} -t https://google.com,https://prometheus.io\n```\nor\n```sh\n$ docker run -p \"9271:9271\" --rm \\\n    --env PAGESPEED_API_KEY={KEY} \\\n    --env PAGESPEED_TARGETS=https://google.com,https://prometheus.io \\\n    --env PAGESPEED_CATEGORIES=accessibility,pwa \\\n    foomo/pagespeed_exporter\n```\n\n\n### Prometheus \u0026 Docker Compose\n\nCheck out the docker-compose folder\n\n### Kubernetes/Helm\n\nYou can install the included [Helm](https://docs.helm.sh/install/) chart to your k8s cluster with:\n\n```\n$ helm install helm/pagespeed-exporter\n```\n\nAnd then, to quickly test it:\n```\n$ kubectl get pods\npagespeed-exporter-riotous-dragonfly-6b99955999-hj2kw   1/1     Running   0          1m\n\n$ kubectl exec -ti pagespeed-exporter-riotous-dragonfly-6b99955999-hj2kw -- sh\n# apk add curl\n# curl localhost:9271/metrics\npagespeed_lighthouse_audit_score{audit=\"first-contentful-paint\",host=\"https://www.google.com\",path=\"/\",strategy=\"mobile\"} 1\npagespeed_lighthouse_audit_score{audit=\"first-contentful-paint\",host=\"https://www.google.com\",path=\"/webhp\",strategy=\"desktop\"} 1\npagespeed_lighthouse_audit_score{audit=\"first-contentful-paint\",host=\"https://www.google.com\",path=\"/webhp\",strategy=\"mobile\"} 1\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoomo%2Fpagespeed_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoomo%2Fpagespeed_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoomo%2Fpagespeed_exporter/lists"}