Skip to content

add a diff field for monitoring usages #71

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zffocussss
Copy link

@zffocussss zffocussss commented Apr 11, 2025

it is designed to monitor if the cvd is uptodate.In my cases promethues + Blackbox-exporter.
in other words,if the value of diff is not 0,it means the cvd is required to check in time in case of expiration.

@zffocussss
Copy link
Author

@benzino77
Please have a check,it is useful in a k8s monitor stack.

@benzino77
Copy link
Owner

I have no experience using balckbox-exporter but does using fail_if_body_json_matches_cel or fail_if_body_json_not_matches_cel not solve the problem (compare two values from returned json)?
There is an example in the documentation of blackbox-exporter https://github.com/prometheus/blackbox_exporter/blob/c9a32f5aafdb00e9f0059964880fb021fcb4cdf8/example.yml#L67

More information about CEL-SPEC is available here: https://github.com/google/cel-spec

@zffocussss
Copy link
Author

zffocussss commented Apr 14, 2025

I have no experience using balckbox-exporter but does using fail_if_body_json_matches_cel or fail_if_body_json_not_matches_cel not solve the problem (compare two values from returned json)? There is an example in the documentation of blackbox-exporter https://github.com/prometheus/blackbox_exporter/blob/c9a32f5aafdb00e9f0059964880fb021fcb4cdf8/example.yml#L67

More information about CEL-SPEC is available here: https://github.com/google/cel-spec

@benzino77 In my opinion,add a diff field in the response body for some data collectors is much more valuable,as it can reduce client work.

@benzino77
Copy link
Owner

I'm not super convinced to that idea. The localVersion and/or remoteVersion can be also something like: 1744738140a or 1744738140d then calculating a diff based on Number will end up with NaN (I think). Implementing that logic on Blackbox-Reporter side and having there just a boolean value: True (for same versions) and False (for different versions) may be a better approach.

@zffocussss
Copy link
Author

I'm not super convinced to that idea. The localVersion and/or remoteVersion can be also something like: 1744738140a or 1744738140d then calculating a diff based on Number will end up with NaN (I think). Implementing that logic on Blackbox-Reporter side and having there just a boolean value: True (for same versions) and False (for different versions) may be a better approach.

So far,the database version is number.It is safe to use Number type to calculate the diff between local and remote.

@benzino77
Copy link
Owner

Still it can give "NaN" in case of situation when letters are added to the version:

> const a = "1234567"
undefined
> const b = "1234567a"
undefined
> const c = Number(a) - Number (b)
undefined
> c
NaN

I do believe that having that logic on "consumer" side is better approach.

@zffocussss
Copy link
Author

zffocussss commented Apr 22, 2025

Still it can give "NaN" in case of situation when letters are added to the version:

> const a = "1234567"
undefined
> const b = "1234567a"
undefined
> const c = Number(a) - Number (b)
undefined
> c
NaN

I do believe that having that logic on "consumer" side is better approach.

if you insist on the type of version,how about the below response.

{
    "data": {
        "diff": true,
        "local_clamav_db_signature": "27615",
        "remote_clamav_db_signature": "27615"
    },
    "success": true
}

in this case,if diff is true,it means the version need to be checked.
diff: remoteVersion === localVersion,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants