Skip to content
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

#65 Fixes No value passed error in prometheus metrics #66

Merged
merged 1 commit into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [Unreleased](https://github.com/idealista/nginx_role/tree/develop)
### Fixed
- *[#65](https://github.com/idealista/nginx_role/issues/65) No value passed error in prometheus metrics* @jmonterrubio

## [2.1.0](https://github.com/idealista/nginx_role/tree/2.1.0) (2019-09-09)
[Full Changelog](https://github.com/idealista/nginx_role/compare/2.1.0...2.0.1)
### Fixed
Expand Down
14 changes: 9 additions & 5 deletions templates/metrics/prometheus.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,20 @@ log_by_lua_block {
upstream_bytes_sent = getWithIndex(ngx.var.upstream_bytes_sent, idx)
end
http_upstream_requests:inc(1, {addr, upstream_status})
http_upstream_response_time:observe(tonumber(upstream_response_time), {addr})
http_upstream_header_time:observe(tonumber(upstream_header_time), {addr})
if upstream_response_time ~= nil and tonumber(upstream_response_time) ~= nil then
http_upstream_response_time:observe(tonumber(upstream_response_time), {addr})
end
if http_upstream_header_time ~= nil and tonumber(http_upstream_header_time) ~= nil then
http_upstream_header_time:observe(tonumber(upstream_header_time), {addr})
end
-- ngx.config.nginx_version >= 1011004
if upstream_first_byte_time ~= nil then
if upstream_first_byte_time ~= nil and tonumber(upstream_first_byte_time) ~= nil then
http_upstream_first_byte_time:observe(tonumber(upstream_first_byte_time), {addr})
end
if upstream_connect_time ~= nil then
if upstream_connect_time ~= nil and tonumber(upstream_connect_time) ~= nil then
http_upstream_connect_time:observe(tonumber(upstream_connect_time), {addr})
end
if upstream_session_time ~= nil then
if upstream_session_time ~= nil and tonumber(upstream_session_time) ~= nil then
http_upstream_session_time:observe(tonumber(upstream_session_time), {addr})
end
if upstream_bytes_received ~= nil then
Expand Down