Add source and port tags to jenkins plugin (#6641)

This commit is contained in:
Nick Neisen 2019-11-13 14:38:33 -07:00 committed by Daniel Nelson
parent 48c271640c
commit 0c918b099b
3 changed files with 13 additions and 2 deletions

View File

@ -8,7 +8,7 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
```toml
[[inputs.jenkins]]
## The Jenkins URL
## The Jenkins URL in the format "schema://host:port"
url = "http://my-jenkins-instance:8080"
# username = "admin"
# password = "admin"
@ -59,6 +59,7 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
- temp_path
- node_name
- status ("online", "offline")
- source
- fields:
- disk_available
- temp_available
@ -74,6 +75,7 @@ This plugin does not require a plugin on jenkins and it makes use of Jenkins API
- name
- parents
- result
- source
- fields:
- duration
- result_code (0 = SUCCESS, 1 = FAILURE, 2 = NOT_BUILD, 3 = UNSTABLE, 4 = ABORTED)

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"sync"
@ -43,7 +44,7 @@ type Jenkins struct {
}
const sampleConfig = `
## The Jenkins URL
## The Jenkins URL in the format "schema://host:port"
url = "http://my-jenkins-instance:8080"
# username = "admin"
# password = "admin"
@ -190,6 +191,13 @@ func (j *Jenkins) gatherNodeData(n node, acc telegraf.Accumulator) error {
tags["status"] = "offline"
}
u, err := url.Parse(j.URL)
if err != nil {
return err
}
tags["source"] = u.Hostname()
tags["port"] = u.Port()
fields := make(map[string]interface{})
fields["num_executors"] = n.NumExecutors

View File

@ -181,6 +181,7 @@ func TestGatherNodeData(t *testing.T) {
"status": "online",
"disk_path": "/path/1",
"temp_path": "/path/2",
"source": "127.0.0.1",
},
Fields: map[string]interface{}{
"response_time": int64(10032),