tuckerconnelly / puppeteer-assets

Assets metrics using Puppeteer and Prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Puppeteer Assets npm version Build Status

Gets assets metrics using Puppeteer.

Want to know which scripts are loaded in your page? This module allows you to extract and audit the metrics.

CLI-output

Set up

npm install puppeteer-assets

Usage

Using CLI

puppeteer-assets www.google.com

Using on Node.js

const assetsMetrics = require('puppeteer-assets');

const metrics = await assetsMetrics('https://www.google.com');

Prometheus

Exports assets metrics via HTTP for Prometheus consumption.

Grafana

Use docker image:

docker run --name=prometheus-assets -d -p 3000:3000 andersonba/prometheus-assets

Now, in your Prometheus configuration (/etc/prometheus/prometheus.yml), add a new target.

You can monitor multiple URLs passing params each scrape config. See example

If you prefer use a configuration file, create a config.yml file. Then, run the container defining the volume:

docker run --name=prometheus-assets -v /tmp/config.yml:/app/prometheus/ -d -p 3000:3000 andersonba/prometheus-assets

Reference

assetsMetrics(url, options)

Execute the command

Parameters
  • url - Required. Page URL.
  • options.internalPattern - String/Regex. Identify scripts as Internal based on RegExp (Default: null)
  • options.mimeTypes - Array of String/RegExp. File types to be matched (Default: 'javascript')

About

Assets metrics using Puppeteer and Prometheus

License:MIT License


Languages

Language:JavaScript 92.8%Language:Dockerfile 4.5%Language:Shell 2.8%