unit icon indicating copy to clipboard operation
unit copied to clipboard

How to extract metrics

Open daniel-blake opened this issue 4 years ago • 6 comments

A customer needs me to retrieve metrics (for prometheus) from a number of nginx-unit docker images. Is there currently a way to retrieve those, and if so, what are the necessary steps?

The metrics are a requirement of the setup, so if they're not available I need to start work on another solution.

daniel-blake avatar May 12 '20 15:05 daniel-blake

Hi, @daniel-blake,

What kind of metrics are we talking about here? Currently, Unit forwards its access log to Docker container log, if it's any help to your cause.

artemkonev avatar May 13 '20 15:05 artemkonev

We're looking for metrics like those exposed in the nginx stub_status:

  • The current number of active client connections including Waiting connections.
  • The total number of accepted client connections.
  • The total number of handled connections.
  • The total number of client requests.
  • The current number of connections where nginx is reading the request header.
  • The current number of connections where nginx is writing the response back to the client.
  • The current number of idle client connections waiting for a request.

Not all are needed. We're also looking for metrics from the php subsystem, like:

  • Memory usage
  • Number of active processes

The precise metrics aren't set in stone, but the above is the ballpark estimate of what we need.

daniel-blake avatar May 15 '20 18:05 daniel-blake

Thanks for the elaboration, Daniel. Unfortunately, this goes beyond Unit's capabilities at the moment. However, you can suggest specific metrics to be implemented in the future, as we're making mental notes of user concerns like this one.

artemkonev avatar May 16 '20 11:05 artemkonev

Good day! Any news on getting metrics from the app? The project is actively developing, but it is impossible to introduce it into the product without metrics.

rowerok-it avatar Jun 03 '21 19:06 rowerok-it

Just a reminder from 2022.

livelace avatar Mar 27 '22 08:03 livelace

Hi

Here's the patch of metrics exported from Unit. https://gist.github.com/hongzhidao/79ace78851667e50474623f9d191aeab

Have a try:

  1. start
> ./build/unitd --control 127.0.0.1:8000
  1. get status
> curl http://127.1:8000/status
{
	"connections": {
		"accepted": 0,
		"active": 0,
		"idle": 0,
		"closed": 0
	},

	"requests": {},
	"applications": {}
}

Or

> curl http://127.1:8000/status/connections
{
	"accepted": 0,
	"active": 0,
	"idle": 0,
	"closed": 0
}

Currently, we only support very basic statistics, welcome to suggest more metrics.

hongzhidao avatar May 16 '22 09:05 hongzhidao

Hi, We just committed the statistics patch, and it'll be in the 1.28 version. Welcome more suggestions on statistics, thanks.

hongzhidao avatar Sep 05 '22 10:09 hongzhidao