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

Onbuild #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions plugins/inputs/grafana/api/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@ import (
"errors"
"fmt"
"io/ioutil"
"time"
)

type DashboardMeta struct {
IsStarred bool `json:"isStarred"`
URL string `json:"url"`
IsStarred bool `json:"isStarred,omitempty"`
IsHome bool `json:"isHome,omitempty"`
IsSnapshot bool `json:"isSnapshot,omitempty"`
Type string `json:"type,omitempty"`
CanSave bool `json:"canSave"`
CanEdit bool `json:"canEdit"`
CanAdmin bool `json:"canAdmin"`
CanStar bool `json:"canStar"`
Slug string `json:"slug"`
Expires time.Time `json:"expires"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
UpdatedBy string `json:"updatedBy"`
CreatedBy string `json:"createdBy"`
HasAcl bool `json:"hasAcl"`
IsFolder bool `json:"isFolder"`
FolderId int64 `json:"folderId"`
FolderTitle string `json:"folderTitle"`
FolderUrl string `json:"folderUrl"`
Provisioned bool `json:"provisioned"`
ProvisionedExternalId string `json:"provisionedExternalId,omitempty"`
}

type Dashboard struct {
Expand Down
14 changes: 13 additions & 1 deletion plugins/inputs/grafana/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Grafana struct {
Host string `toml:"host"`
Authorization string `toml:"authorization"`
Dashboard bool `toml:"dashboard"`
Meta bool `toml:"meta"`
Datasource bool `toml:"datasource"`
}

Expand All @@ -26,6 +27,7 @@ var sampleConfig = `
host = "http://<host>:<port>" # required
authorization = "Bearer <token>" # required
dashboard = true # true if dashboard needs to be fetched; default true
meta = true # true if dashboard metadata is required while fetching; default true
datasource = true # true if datasource needs to be fetched; default true
`

Expand Down Expand Up @@ -77,7 +79,17 @@ func (s *Grafana) Process(acc gde.Accumulator) error {
if err != nil {
return err
}
byts, err := json.Marshal(dashboard.Model)

// Remove generic keys
delete(dashboard.Model, "id")
delete(dashboard.Model, "uid")
delete(dashboard.Model, "version")

var obj interface{} = dashboard
if s.Meta {
obj = dashboard.Model
}
byts, err := json.Marshal(obj)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#### gde Variables
################

##############################################################################
# Usage: python scripts/build.py --clean --package --release --version 1.0.0 #
##############################################################################

# Packaging variables
PACKAGE_NAME = "gde"
INSTALL_ROOT_DIR = "/usr/bin"
Expand Down Expand Up @@ -847,4 +851,4 @@ def main(args):
help='Timeout for tests before failing')
args = parser.parse_args()
print_banner()
sys.exit(main(args))
sys.exit(main(args))