-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The problem with different cardinality of labels on prometheus nodes …
…should now be solved
- Loading branch information
1 parent
8f7d9d8
commit be09698
Showing
2 changed files
with
44 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
43 changes: 43 additions & 0 deletions
43
src/github.com/dereulenspiegel/node-informant/gluon-collector/prometheus/pipes_test.go
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,43 @@ | ||
package prometheus | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/dereulenspiegel/node-informant/gluon-collector/config" | ||
"github.com/dereulenspiegel/node-informant/gluon-collector/data" | ||
cfg "github.com/olebedev/config" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var ( | ||
testConfig = ` | ||
prometheus: | ||
namelabel: true | ||
sitecodelabel: true | ||
` | ||
) | ||
|
||
func TestCreationOfPrometheusLabels(t *testing.T) { | ||
assert := assert.New(t) | ||
nodeinfo := data.NodeInfo{ | ||
Hostname: "Testnode", | ||
System: data.SystemStruct{ | ||
SiteCode: "fftest", | ||
}, | ||
NodeId: "1122", | ||
} | ||
var err error | ||
config.Global, err = cfg.ParseYaml(testConfig) | ||
assert.Nil(err) | ||
|
||
prmcfg, err := config.Global.Get("prometheus") | ||
assert.Nil(err) | ||
assert.NotNil(prmcfg) | ||
|
||
nodeLabels := getLabels(nodeinfo, "metric") | ||
assert.Equal(4, len(nodeLabels)) | ||
assert.Equal("1122", nodeLabels[0]) | ||
assert.Equal("Testnode", nodeLabels[1]) | ||
assert.Equal("fftest", nodeLabels[2]) | ||
assert.Equal("metric", nodeLabels[3]) | ||
} |