Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
k8s-ingress
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-ingress
Commits
ad6cd3bc
Commit
ad6cd3bc
authored
Jan 16, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the backend_services and backend_endpoints gauges.
parent
1ff7b034
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
metrics.go
pkg/varnish/metrics.go
+18
-0
varnish.go
pkg/varnish/varnish.go
+14
-0
No files found.
pkg/varnish/metrics.go
View file @
ad6cd3bc
...
...
@@ -76,6 +76,22 @@ var (
Help
:
"Current number of known admin secrets"
,
})
beSvcsGauge
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"backend_services"
,
Help
:
"Current number of Services configured as Varnish "
+
"backends"
,
})
beEndpsGauge
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Namespace
:
namespace
,
Subsystem
:
subsystem
,
Name
:
"backend_endpoints"
,
Help
:
"Current number of Service endpoints configured "
+
"as Varnish backends"
,
})
monResultCtr
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Namespace
:
namespace
,
Subsystem
:
subsystem
,
...
...
@@ -100,6 +116,8 @@ func initMetrics() {
prometheus
.
Register
(
instsGauge
)
prometheus
.
Register
(
secretsGauge
)
prometheus
.
Register
(
monResultCtr
)
prometheus
.
Register
(
beSvcsGauge
)
prometheus
.
Register
(
beEndpsGauge
)
}
func
getInstanceMetrics
(
addr
string
)
*
instanceMetrics
{
...
...
pkg/varnish/varnish.go
View file @
ad6cd3bc
...
...
@@ -546,6 +546,19 @@ func (vc *VarnishController) DeleteVarnishSvc(key string) error {
return
err
}
func
(
vc
*
VarnishController
)
updateBeGauges
()
{
nBeSvcs
:=
0
nBeEndps
:=
0
for
_
,
svc
:=
range
vc
.
svcs
{
nBeSvcs
+=
len
(
svc
.
spec
.
spec
.
AllServices
)
for
_
,
beSvc
:=
range
svc
.
spec
.
spec
.
AllServices
{
nBeEndps
+=
len
(
beSvc
.
Addresses
)
}
}
beSvcsGauge
.
Set
(
float64
(
nBeSvcs
))
beEndpsGauge
.
Set
(
float64
(
nBeEndps
))
}
// Update a Varnish Service to implement an Ingress.
//
// svcKey: namespace/name key for the Service
...
...
@@ -570,6 +583,7 @@ func (vc *VarnishController) Update(
svc
.
spec
.
key
=
ingKey
svc
.
spec
.
uid
=
uid
svc
.
spec
.
spec
=
spec
vc
.
updateBeGauges
()
if
len
(
svc
.
instances
)
==
0
{
return
fmt
.
Errorf
(
"Ingress %s uid=%s: Currently no known "
+
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment