-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose metrics for prometheus to scrape (#83)
- Loading branch information
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2024 Canonical Ltd. | ||
|
||
/* | ||
* Metrics package is used to expose the metrics of the NSSF service. | ||
*/ | ||
|
||
package metrics | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/omec-project/nssf/logger" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
) | ||
|
||
// InitMetrics initialises NSSF metrics | ||
func InitMetrics() { | ||
http.Handle("/metrics", promhttp.Handler()) | ||
if err := http.ListenAndServe(":8080", nil); err != nil { | ||
logger.InitLog.Errorf("Could not open metrics port: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters