Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
246 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
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
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,117 @@ | ||
# possible values : production, development | ||
app_mode = production | ||
|
||
# instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty | ||
instance_name = ${HOSTNAME} | ||
|
||
#################################### Server ############################## | ||
[server] | ||
# Protocol (http, https, socket) | ||
protocol = http | ||
|
||
# The ip address to bind to, empty will bind to all interfaces | ||
http_addr = | ||
|
||
# The http port to use | ||
http_port = 3000 | ||
|
||
# The public facing domain name used to access grafana from a browser | ||
domain = localhost | ||
|
||
# Redirect to correct domain if host header does not match domain | ||
# Prevents DNS rebinding attacks | ||
enforce_domain = false | ||
|
||
# The full public facing url | ||
root_url = %(protocol)s://%(domain)s:%(http_port)s/ | ||
|
||
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons. | ||
serve_from_sub_path = false | ||
|
||
# Log web requests | ||
router_logging = false | ||
|
||
# the path relative working path | ||
static_root_path = public | ||
|
||
# enable gzip | ||
enable_gzip = false | ||
|
||
#################################### Users ############################### | ||
[users] | ||
# disable user signup / registration | ||
allow_sign_up = false | ||
|
||
# Allow non admin users to create organizations | ||
allow_org_create = false | ||
|
||
# Set to true to automatically assign new users to the default organization (id 1) | ||
auto_assign_org = true | ||
|
||
# Set this value to automatically add new users to the provided organization (if auto_assign_org above is set to true) | ||
auto_assign_org_id = 1 | ||
|
||
# Default role new users will be automatically assigned (if auto_assign_org above is set to true) | ||
auto_assign_org_role = Viewer | ||
|
||
# Require email validation before sign up completes | ||
verify_email_enabled = false | ||
|
||
# Background text for the user field on the login page | ||
login_hint = email or username | ||
password_hint = password | ||
|
||
# Default UI theme ("dark" or "light") | ||
default_theme = dark | ||
|
||
# Viewers can edit/inspect dashboard settings in the browser. But not save the dashboard. | ||
viewers_can_edit = false | ||
|
||
# Editors can administrate dashboard, folders and teams they create | ||
editors_can_admin = false | ||
|
||
#################################### Alerting ############################ | ||
[alerting] | ||
# Disable alerting engine & UI features | ||
enabled = true | ||
# Makes it possible to turn off alert rule execution but alerting UI is visible | ||
execute_alerts = true | ||
|
||
# Default setting for new alert rules. Defaults to categorize error and timeouts as alerting. (alerting, keep_state) | ||
error_or_timeout = alerting | ||
|
||
# Default setting for how Grafana handles nodata or null values in alerting. (alerting, no_data, keep_state, ok) | ||
nodata_or_nullvalues = no_data | ||
|
||
# Alert notifications can include images, but rendering many images at the same time can overload the server | ||
# This limit will protect the server from render overloading and make sure notifications are sent out quickly | ||
concurrent_render_limit = 5 | ||
|
||
# Default setting for alert calculation timeout. Default value is 30 | ||
evaluation_timeout_seconds = 30 | ||
|
||
# Default setting for alert notification timeout. Default value is 30 | ||
notification_timeout_seconds = 30 | ||
|
||
# Default setting for max attempts to sending alert notifications. Default value is 3 | ||
max_attempts = 3 | ||
|
||
[auth] | ||
# Login cookie name | ||
login_cookie_name = grafana_session | ||
|
||
# The lifetime (days) an authenticated user can be inactive before being required to login at next visit. Default is 7 days. | ||
login_maximum_inactive_lifetime_days = 7 | ||
|
||
# The maximum lifetime (days) an authenticated user can be logged in since login time before being required to login. Default is 30 days. | ||
login_maximum_lifetime_days = 30 | ||
|
||
# How often should auth tokens be rotated for authenticated users when being active. The default is each 10 minutes. | ||
token_rotation_interval_minutes = 10 | ||
|
||
# Set to true to disable (hide) the login form, useful if you use OAuth | ||
disable_login_form = false | ||
|
||
#################################### Basic Auth ########################## | ||
[auth.basic] | ||
enabled = true |
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,31 @@ | ||
package main | ||
|
||
deny[msg] { | ||
not input.alerting.enabled = "true" | ||
msg = "Alerting should turned on" | ||
} | ||
|
||
deny[msg] { | ||
not input["auth.basic"].enabled = "true" | ||
msg = "Basic auth should be enabled" | ||
} | ||
|
||
deny[msg] { | ||
not input.server.http_port = "3000" | ||
msg = "Grafana port should be 3000" | ||
} | ||
|
||
deny[msg] { | ||
not input.server.protocol = "http" | ||
msg = "Grafana should use default http" | ||
} | ||
|
||
deny[msg] { | ||
not input.users.allow_sign_up = "false" | ||
msg = "Users cannot sign up themselves" | ||
} | ||
|
||
deny[msg] { | ||
not input.users.verify_email_enabled = "true" | ||
msg = "Users should verify their e-mail address" | ||
} |
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
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
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,42 @@ | ||
package ini | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/ghodss/yaml" | ||
"github.com/go-ini/ini" | ||
) | ||
|
||
type Parser struct { | ||
FileName string | ||
} | ||
|
||
func (i *Parser) Unmarshal(p []byte, v interface{}) error { | ||
filePath, _ := filepath.Abs(i.FileName) | ||
result := map[string]map[string]string{} | ||
cfg, err := ini.Load(filePath) | ||
if err != nil { | ||
return fmt.Errorf("Fail to read ini file: %v", err) | ||
} | ||
|
||
sections := cfg.Sections() | ||
for _, s := range sections { | ||
sectionName := s.Name() | ||
if sectionName == "DEFAULT" { | ||
continue | ||
} | ||
result[sectionName] = map[string]string{} | ||
result[sectionName] = s.KeysHash() | ||
} | ||
j, err := json.Marshal(result) | ||
if err != nil { | ||
return fmt.Errorf("Error trying to parse ini to json: %s", err) | ||
} | ||
err = yaml.Unmarshal(j, v) | ||
if err != nil { | ||
return fmt.Errorf("Unable to parse YAML from ini-json %s: %s", i.FileName, err) | ||
} | ||
return nil | ||
} |
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,27 @@ | ||
package ini | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIniParser(t *testing.T) { | ||
parser := &Parser{ | ||
FileName: "sample.ini", | ||
} | ||
|
||
var input interface{} | ||
err := parser.Unmarshal(nil, &input) | ||
if err != nil { | ||
t.Fatalf("parser should not have thrown an error: %v", err) | ||
} | ||
|
||
if input == nil { | ||
t.Error("There should be information parsed but its nil") | ||
} | ||
|
||
inputMap := input.(map[string]interface{}) | ||
item := inputMap["Local Varaibles"] | ||
if len(item.(map[string]interface{})) <= 0 { | ||
t.Error("There should be at least one item defined in the parsed file, but none found") | ||
} | ||
} |
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,10 @@ | ||
[Local Varaibles] | ||
Name=name | ||
Title=title | ||
Visisbility=show/hide | ||
|
||
[Navigation Controls] | ||
OnNext=node path | ||
Help=help file | ||
|
||
# Test comment |
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