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

Add an option to expose Prometheus metrics via http/s server #839

Merged

Conversation

bszirtes
Copy link
Contributor

Description

Initialized Prometheus metric types and expanded current metrics to push values into Prometheus too, if enabled.

Issue link

networkservicemesh/sdk#1652

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionality
  • Documentation
  • Refactoring
  • CI

@bszirtes bszirtes force-pushed the prometheus-without-otel branch from 80fea91 to 5e2f8fb Compare July 29, 2024 14:31
@bszirtes bszirtes force-pushed the prometheus-without-otel branch 5 times, most recently from 0fc738e to 726928e Compare August 21, 2024 08:46
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Could you fix linter?

@bszirtes
Copy link
Contributor Author

Hi @denis-tingaikin,

Thank you for the feedback! Regarding the linter issue, do you have any recommendations on where to initialize the Prometheus metric types? I'm considering moving the content of my init function (since that's causing the linting issue) into a new function and calling it directly from the forwarder. Would that be a better approach?

@denis-tingaikin
Copy link
Member

I think we can define static sync.Once in the stats/prometheus and do initialization in the NewServer function if promeheus enabled.

@bszirtes
Copy link
Contributor Author

May I ask which specific NewServer function you are referring to @denis-tingaikin?

@denis-tingaikin
Copy link
Member

Sure, I'd try something like this:

in the prometheus.go

package stats

+ import "sync"

+ var prometheusInitOnce sync.Once

-  func init() {
+ func registerMetrics() {
+   if !prometheus.Enabled() {
+     return  
+   }
  ...
}

Then we could initiate it in the stats client/server https://github.com/networkservicemesh/sdk-vpp/blob/main/pkg/networkservice/metrics/stats/server.go#L44, https://github.com/networkservicemesh/sdk-vpp/blob/main/pkg/networkservice/metrics/stats/client.go#L46

via adding one line

prometheusInitOnce.Do(registerMetrics)

@bszirtes bszirtes force-pushed the prometheus-without-otel branch 2 times, most recently from 19a731f to 7acdd19 Compare August 26, 2024 15:08
Signed-off-by: Botond Szirtes <botond.szirtes@est.tech>
@bszirtes bszirtes force-pushed the prometheus-without-otel branch from 7acdd19 to 760a289 Compare August 26, 2024 15:12
@bszirtes
Copy link
Contributor Author

Hi @denis-tingaikin,

Thank you for the clarification! I've made the changes as you recommended.

@denis-tingaikin denis-tingaikin merged commit 441b551 into networkservicemesh:main Aug 27, 2024
13 checks passed
nsmbot pushed a commit to networkservicemesh/cmd-nse-simple-vl3-docker that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-lb-vl3-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-icmp-responder-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-simple-docker that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vl3-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-firewall-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-forwarder-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vlan-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-vpp that referenced this pull request Aug 27, 2024
…k-vpp@main

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nsc-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#713)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nse-icmp-responder-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#695)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-lb-vl3-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#97)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nse-vl3-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#358)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nse-firewall-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#531)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nse-simple-vl3-docker that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#261)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nsc-vpp@main

PR link: networkservicemesh/cmd-nsc-vpp#713

Commit: 05a2533
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:23 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#713)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nsc-simple-docker that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#247)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-lb-vl3-vpp@main

PR link: networkservicemesh/cmd-lb-vl3-vpp#97

Commit: 188e92b
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:29 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#97)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nse-icmp-responder-vpp@main

PR link: networkservicemesh/cmd-nse-icmp-responder-vpp#695

Commit: 75cd411
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:28 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#695)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/cmd-nse-vlan-vpp that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…k-vpp@main (#503)

PR link: networkservicemesh/sdk-vpp#839

Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
  - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nse-vl3-vpp@main

PR link: networkservicemesh/cmd-nse-vl3-vpp#358

Commit: d148d84
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:30 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#358)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nse-firewall-vpp@main

PR link: networkservicemesh/cmd-nse-firewall-vpp#531

Commit: 0e87f1f
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:31 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#531)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nse-simple-vl3-docker@main

PR link: networkservicemesh/cmd-nse-simple-vl3-docker#261

Commit: 97c8bdc
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:34 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#261)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nsc-simple-docker@main

PR link: networkservicemesh/cmd-nsc-simple-docker#247

Commit: 393f898
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:44 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#247)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nse-vlan-vpp@main

PR link: networkservicemesh/cmd-nse-vlan-vpp#503

Commit: 36b1daa
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:50 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#503)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…d-lb-vl3-vpp@main (#12256)

PR link: networkservicemesh/cmd-lb-vl3-vpp#97

Commit: 188e92b
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:29 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#97)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…d-nsc-vpp@main (#12266)

PR link: networkservicemesh/cmd-nsc-vpp#713

Commit: 05a2533
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:23 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#713)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…d-nse-firewall-vpp@main (#12185)

PR link: networkservicemesh/cmd-nse-firewall-vpp#531

Commit: 0e87f1f
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:31 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#531)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…d-nse-simple-vl3-docker@main (#12132)

PR link: networkservicemesh/cmd-nse-simple-vl3-docker#261

Commit: 97c8bdc
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:34 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#261)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot added a commit to networkservicemesh/deployments-k8s that referenced this pull request Aug 27, 2024
…d-nsc-simple-docker@main (#12184)

PR link: networkservicemesh/cmd-nsc-simple-docker#247

Commit: 393f898
Author: Network Service Mesh Bot
Date: 2024-08-26 21:04:44 -0500
Message:
  - Update go.mod and go.sum to latest version from networkservicemesh/sdk-vpp@main (#247)
PR link: networkservicemesh/sdk-vpp#839
Commit: 441b551
Author: Botond Szirtes
Date: 2024-08-27 04:01:09 +0200
Message:
    - Add an option to expose Prometheus metrics via http/s server (#839)

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Co-authored-by: NSMBot <nsmbot@networkservicmesh.io>
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.

None yet

2 participants