To export your first metric to Prometheus, you should call Prometheus::addGauge method. This can be done anywhere in your code, but typically it's done in the app/Providers/PrometheusServiceProvider.php file that was published when installing the package.
When exporting the metrics, a namespace value will be prefixed to the metric name. By default, the namespace is set to app. So, when you export a gauge named User count, the metric name will be app_user_count.
You can change the default namespace in the namespace key of the config/prometheus.php file.
To change the namespace of a specific gauge, you can chain the namespace method.
Labels are a powerful feature of Prometheus. They allow you to add additional dimensions to your metrics. For example, you can add a label to the User count gauge to distinguish between active and inactive users.
To start using a label, you should call the label method on the gauge and pass the label name.
The callable passed to value should return an array of tuples. Each tuple should contain the value and an array of labels. The number of labels should match the number of labels defined on the gauge.