Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Nginx Unit endpoint /about #928

Closed
Pavlusha311245 opened this issue Aug 23, 2023 · 9 comments · May be fixed by #1089
Closed

Enhancement: Nginx Unit endpoint /about #928

Pavlusha311245 opened this issue Aug 23, 2023 · 9 comments · May be fixed by #1089
Labels
z-enhancement ⬆️ Product Enhancement

Comments

@Pavlusha311245
Copy link

Can an endpoint /about or other similarly named endpoint be added to display nginx unit version data?
For example version, what socket or address is used and what configuration settings.
Data can be obtained using the unitd and unitd --version commands.
I'd help with development, but I'm weak in C development 😔

@hongzhidao
Copy link
Contributor

Hi @Pavlusha311245
Thanks that you'd like to contribute on the project.

Can an endpoint /about or other similarly named endpoint be added to display nginx unit version data?

You could refer to these first about the exported information. Make what information exported clear first.
a. exported ngx object in njs:
https://nginx.org/en/docs/njs/reference.html#ngx
b. exported ngx information in nginx plus.
https://nginx.org/en/docs/http/ngx_http_api_module.html#def_nginx_object

Data can be obtained using the unitd and unitd --version commands.

I would suggest exporting it from unit status API. Adding an new object like "unit" at the top.
https://unit.nginx.org/usagestats/

I'd help with development, but I'm weak in C development

You could have a try with it, I'd like to help you if possible. Related source files:

src/nxt_status.h
src/nxt_status.c
build/include/nxt_version.h
build/include/nxt_auto_config.h

Btw, we need to discuss it internally about the feature's priority and if it's necessary to add into Unit.

@Pavlusha311245
Copy link
Author

Pavlusha311245 commented Aug 23, 2023

Can you @hongzhidao put the issue label Enhancement?

You could have a try with it, I'd like to help you if possible. Related source files:

I'll see what I can do.)

@hongzhidao hongzhidao added the z-enhancement ⬆️ Product Enhancement label Aug 23, 2023
Pavlusha311245 pushed a commit to Pavlusha311245/unit that referenced this issue Aug 28, 2023
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Aug 28, 2023
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Aug 28, 2023
@Pavlusha311245
Copy link
Author

@hongzhidao I'm in the process of doing this, but you can correct me if there is already a problem somewhere

@hongzhidao
Copy link
Contributor

Hi @Pavlusha311245,
Now it's clear to provide /status/unit with information like version, others are not clear yet, but we'll discuss them internally.

curl http://127.1:8000/status
{
	"unit": {
		"version": "1.31.0"
	},

	...
}

I'm considering providing related configuration information like load_time and generation. For example:

{
	"unit": {
		"version": "1.31.0",
                "load_time": "2023-08-29T10:10:40.101Z",
                "generation": 12
	},

	...
}

load_time represents the last reconfiguration time.
generation is the total number of configuration reloads.

Would you like to have a try to support them?
Note the control process provides the status API, and the configuration also happens in the same process.

Thanks.

@Pavlusha311245
Copy link
Author

Pavlusha311245 commented Aug 29, 2023

Hi @hongzhidao
Of course, I'll try to add data as well. But it will take a lot of time for now. My main stack is PHP :)

@hongzhidao
Copy link
Contributor

No rush at all.
With the two information, it can help you understand how to handle time with a specific format, unit processes, especially controller process, and what happens about the reconfiguration. It might take you much time to understand them before implementation.

Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Dec 28, 2023
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Dec 28, 2023
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Dec 30, 2023
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 21, 2024
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 24, 2024
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 24, 2024
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 24, 2024
@Pavlusha311245
Copy link
Author

Pavlusha311245 commented Jan 24, 2024

@hongzhidao Hello after almost six months 😊. I was still able to find time and finish what I was doing. I understand that this is not ideal, so could you check my changes? feature/unit_about_section branch in my forked repo

@hongzhidao
Copy link
Contributor

hongzhidao commented Jan 25, 2024

Hi @Pavlusha311245
Welcome back, would you mind creating a PR?
Btw, it would be helpful to describe the feature with the first comment of PR and add something like how the new metric looks like. Thanks.

@Pavlusha311245
Copy link
Author

Pavlusha311245 commented Jan 25, 2024

@hongzhidao morning. PR created #1089

Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 25, 2024
Added unit section to /status endpoint. Unit section is about web-server version, config last load time and config update generation
Response example below:
{"unit":{"version":"1.32.0","load_time":"2024-01-25T13:24:08.000Z","generation":0},"connections":{"accepted":0,"active":0,"idle":0,"closed":0},"requests":{"total":0},"applications":{"laravel":{"processes":{"running":1,"starting":0,"idle":1},"requests":{"active":0}}}}
Closes: nginx#928
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Jan 26, 2024
Added unit section to /status endpoint. Unit section is about web-server version, config last load time and config update generation
Response example below:
{"unit":{"version":"1.32.0","load_time":"2024-01-25T13:24:08.000Z","generation":0},"connections":{"accepted":0,"active":0,"idle":0,"closed":0},"requests":{"total":0},"applications":{"laravel":{"processes":{"running":1,"starting":0,"idle":1},"requests":{"active":0}}}}
Closes: nginx#928
@nginx nginx locked and limited conversation to collaborators Jan 26, 2024
@hongzhidao hongzhidao converted this issue into discussion #1092 Jan 26, 2024
Pavlusha311245 added a commit to Pavlusha311245/unit that referenced this issue Oct 27, 2024
Added unit section to /status endpoint. Unit section is about web-server version, config last load time and config update generation
Response example below:
{"unit":{"version":"1.32.0","load_time":"2024-01-25T13:24:08.000Z","generation":0},"connections":{"accepted":0,"active":0,"idle":0,"closed":0},"requests":{"total":0},"applications":{"laravel":{"processes":{"running":1,"starting":0,"idle":1},"requests":{"active":0}}}}
Closes: nginx#928

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
z-enhancement ⬆️ Product Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants