nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.4k stars 327 forks source link

How to extract metrics #427

Closed daniel-blake closed 2 years ago

daniel-blake commented 4 years ago

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.

ghost commented 4 years ago

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.

daniel-blake commented 4 years ago

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

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

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

ghost commented 4 years ago

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.

rowerok-it commented 3 years ago

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.

livelace commented 2 years ago

Just a reminder from 2022.

hongzhidao commented 2 years ago

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
  2. 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 commented 2 years ago

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