Skip to content

Commit

Permalink
Log use of grid-layout flag. Improved flags docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak Marais committed Oct 18, 2019
1 parent 1e45d9b commit 12e4b88
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
25 changes: 15 additions & 10 deletions cmd/grafana-reporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ import (
)

var proto = flag.String("proto", "http://", "Grafana Protocol. Change to 'https://' if Grafana is using https. Reporter will still serve http.")
var ip = flag.String("ip", "localhost:3000", "Grafana IP and port")
var port = flag.String("port", ":8686", "Port to serve on")
var templateDir = flag.String("templates", "templates/", "Directory for custom TeX templates")
var ip = flag.String("ip", "localhost:3000", "Grafana IP and port.")
var port = flag.String("port", ":8686", "Port to serve on.")
var templateDir = flag.String("templates", "templates/", "Directory for custom TeX templates.")
var sslCheck = flag.Bool("ssl-check", true, "Check the SSL issuer and validity. Set this to false if your Grafana serves https using an unverified, self-signed certificate.")
var gridLayout = flag.Bool("grid-layout", false, "Enable grid layout. Panel width and height will be calculated based off Grafana gridPos width and height.")
var gridLayout = flag.Bool("grid-layout", false, "Enable grid layout (-grid-layout=1). Panel width and height will be calculated based off Grafana gridPos width and height.")

//cmd line mode params
var cmdMode = flag.Bool("cmd_enable", false, "Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1)")
var dashboard = flag.String("cmd_dashboard", "", "Dashboard identifier. Required (and only used) in command line mode")
var apiKey = flag.String("cmd_apiKey", "", "Grafana api key. Required (and only used) in command line mode")
var apiVersion = flag.String("cmd_apiVersion", "v5", "Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5")
var outputFile = flag.String("cmd_o", "out.pdf", "Output file. Required (and only used) in command line mode")
var timeSpan = flag.String("cmd_ts", "from=now-3h&to=now", "Time span. Required (and only used) in command line mode")
var cmdMode = flag.Bool("cmd_enable", false, "Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1).")
var dashboard = flag.String("cmd_dashboard", "", "Dashboard identifier. Required (and only used) in command line mode.")
var apiKey = flag.String("cmd_apiKey", "", "Grafana api key. Required (and only used) in command line mode.")
var apiVersion = flag.String("cmd_apiVersion", "v5", "Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5.")
var outputFile = flag.String("cmd_o", "out.pdf", "Output file. Required (and only used) in command line mode.")
var timeSpan = flag.String("cmd_ts", "from=now-3h&to=now", "Time span. Required (and only used) in command line mode.")
var template = flag.String("cmd_template", "", "Specify a custom TeX template file. Only used in command line mode, but is optional even there.")

func main() {
Expand All @@ -55,6 +55,11 @@ func main() {
} else {
log.Printf("SSL check enforced")
}
if !*gridLayout {
log.Printf("Using sequential report layout. Consider enabling 'grid-layout' so that your report more closely follow the dashboard layout.")
} else {
log.Printf("Using grid layout.")
}

router := mux.NewRouter()
RegisterHandlers(
Expand Down
28 changes: 14 additions & 14 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ Query available flags. Likely the only one you need to set is `-ip`.

grafana-reporter --help
-cmd_apiKey string
Grafana api key. Required (and only used) in command line mode
Grafana api key. Required (and only used) in command line mode.
-cmd_apiVersion string
Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5 (default "v5")
Api version: [v4, v5]. Required (and only used) in command line mode, example: -apiVersion v5. (default "v5")
-cmd_dashboard string
Dashboard identifier. Required (and only used) in command line mode
Dashboard identifier. Required (and only used) in command line mode.
-cmd_enable
Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1)
Enable command line mode. Generate report from command line without starting webserver (-cmd_enable=1).
-cmd_o string
Output file. Required (and only used) in command line mode (default "out.pdf")
Output file. Required (and only used) in command line mode. (default "out.pdf")
-cmd_template string
Specify a custom TeX template file. Only used in command line mode, but is optional even there.
Specify a custom TeX template file. Only used in command line mode, but is optional even there.
-cmd_ts string
Time span. Required (and only used) in command line mode (default "from=now-3h&to=now")
Time span. Required (and only used) in command line mode. (default "from=now-3h&to=now")
-grid-layout
Enable grid layout (-grid-layout=1). Panel width and height will be calculated based off Grafana gridPos width and height.
-ip string
Grafana IP and port (default "localhost:3000")
Grafana IP and port. (default "localhost:3000")
-port string
Port to serve on (default ":8686")
Port to serve on. (default ":8686")
-proto string
Grafana Protocol. Change to 'https://' if Grafana is using https. Reporter will still serve http. (default "http://")
Grafana Protocol. Change to 'https://' if Grafana is using https. Reporter will still serve http. (default "http://")
-ssl-check
Check the SSL issuer and validity. Set this to false if your grafana serves https using an unverified self-signed certificate. (default true)
Check the SSL issuer and validity. Set this to false if your Grafana serves https using an unverified, self-signed certificate. (default true)
-templates string
Directory for custom TeX templates (default "templates/")
-grid-layout
Enable grid layout. Panel width and height will be calculated based off Grafana gridPos width and height.
Directory for custom TeX templates. (default "templates/")


### Generate a dashboard report
Expand Down

0 comments on commit 12e4b88

Please sign in to comment.