Documentation
¶
Index ¶
- Constants
- Variables
- func AddChangePasswordLink() bool
- func AddExpander(name string, priority int64, e Expander)
- func ExpandVar(s string) (string, error)
- func GetAlertmanagerDefaultConfiguration() string
- func GetAllowedOriginGlobs(originPatterns []string) ([]glob.Glob, error)
- func RedactedValue(key, value string) string
- func ToAbsUrl(relativeUrl string) string
- type AnnotationCleanupSettings
- type AzureSettings
- type Cfg
- func (cfg *Cfg) GetContentDeliveryURL(prefix string) string
- func (cfg Cfg) IsDatabaseMetricsEnabled() bool
- func (cfg Cfg) IsHTTPRequestHistogramDisabled() bool
- func (cfg Cfg) IsLiveConfigEnabled() bool
- func (cfg Cfg) IsNewNavigationEnabled() bool
- func (cfg Cfg) IsTrimDefaultsEnabled() bool
- func (cfg *Cfg) Load(args CommandLineArgs) error
- func (cfg *Cfg) LogConfigSources()
- func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error
- func (cfg *Cfg) SectionWithEnvOverrides(s string) *DynamicSection
- type CommandLineArgs
- type DateFormatIntervals
- type DateFormats
- type DynamicSection
- type Expander
- type GlobalQuota
- type KeyValue
- type OSSImpl
- func (o OSSImpl) Current() SettingsBag
- func (o OSSImpl) IsFeatureToggleEnabled(name string) bool
- func (o *OSSImpl) KeyValue(section, key string) KeyValue
- func (OSSImpl) RegisterReloadHandler(string, ReloadHandler)
- func (o *OSSImpl) Section(section string) Section
- func (OSSImpl) Update(SettingsBag, SettingsRemovals) error
- type OrgQuota
- type PluginSettings
- type Provider
- type QuotaSettings
- type ReloadHandler
- type RemoteCacheOptions
- type Scheme
- type Section
- type Sentry
- type SettingsBag
- type SettingsRemovals
- type SmtpSettings
- type UnifiedAlertingSettings
- type UserQuota
- type ValidationError
Constants ¶
const ( RedactedPassword = "*********" DefaultHTTPAddr = "0.0.0.0" Dev = "development" Prod = "production" Test = "test" ApplicationName = "Grafana" )
const ( AzurePublic = "AzureCloud" AzureChina = "AzureChinaCloud" AzureUSGovernment = "AzureUSGovernment" AzureGermany = "AzureGermanCloud" )
Variables ¶
var ( // App settings. Env = Dev AppUrl string AppSubUrl string ServeFromSubPath bool InstanceName string // build BuildVersion string BuildCommit string BuildBranch string BuildStamp int64 IsEnterprise bool // packaging Packaging = "unknown" // Paths HomePath string CustomInitPath = "conf/custom.ini" // HTTP server options StaticRootPath string // Security settings. SecretKey string DisableGravatar bool DataProxyWhiteList map[string]bool CookieSecure bool CookieSameSiteDisabled bool CookieSameSiteMode http.SameSite // Snapshots ExternalSnapshotUrl string ExternalSnapshotName string ExternalEnabled bool SnapShotRemoveExpired bool // Dashboard history DashboardVersionsToKeep int MinRefreshInterval string // User settings AllowUserSignUp bool AllowUserOrgCreate bool AutoAssignOrg bool AutoAssignOrgId int AutoAssignOrgRole string VerifyEmailEnabled bool LoginHint string PasswordHint string DisableLoginForm bool DisableSignoutMenu bool SignoutRedirectUrl string ExternalUserMngLinkUrl string ExternalUserMngLinkName string ExternalUserMngInfo string OAuthAutoLogin bool ViewersCanEdit bool // HTTP auth SigV4AuthEnabled bool AnonymousEnabled bool // Auth proxy settings AuthProxyEnabled bool AuthProxyHeaderProperty string // Basic Auth BasicAuthEnabled bool // Global setting objects. Raw *ini.File // analytics GoogleAnalyticsId string GoogleTagManagerId string RudderstackDataPlaneUrl string RudderstackWriteKey string // LDAP LDAPEnabled bool LDAPConfigFile string LDAPSyncCron string LDAPAllowSignup bool LDAPActiveSyncEnabled bool // Quota Quota QuotaSettings // Alerting AlertingEnabled bool ExecuteAlerts bool AlertingRenderLimit int AlertingErrorOrTimeout string AlertingNoDataOrNullValues string AlertingEvaluationTimeout time.Duration AlertingNotificationTimeout time.Duration AlertingMaxAttempts int AlertingMinInterval int64 // Explore UI ExploreEnabled bool // Grafana.NET URL GrafanaComUrl string ImageUploadProvider string )
var (
ErrOperationNotPermitted = errors.New("operation not permitted")
)
Functions ¶
func AddChangePasswordLink ¶
func AddChangePasswordLink() bool
AddChangePasswordLink returns if login form is disabled or not since the same intention can be used to hide both features.
func AddExpander ¶
func GetAlertmanagerDefaultConfiguration ¶
func GetAlertmanagerDefaultConfiguration() string
func GetAllowedOriginGlobs ¶
func RedactedValue ¶
Types ¶
type AzureSettings ¶
type Cfg ¶
type Cfg struct {
Raw *ini.File
Logger log.Logger
// HTTP Server Settings
CertFile string
KeyFile string
HTTPAddr string
HTTPPort string
AppURL string
AppSubURL string
ServeFromSubPath bool
StaticRootPath string
Protocol Scheme
SocketPath string
RouterLogging bool
Domain string
CDNRootURL *url.URL
ReadTimeout time.Duration
EnableGzip bool
EnforceDomain bool
// Security settings
SecretKey string
EmailCodeValidMinutes int
// build
BuildVersion string
BuildCommit string
BuildBranch string
BuildStamp int64
IsEnterprise bool
// packaging
Packaging string
// Paths
HomePath string
ProvisioningPath string
DataPath string
LogsPath string
PluginsPath string
BundledPluginsPath string
// SMTP email settings
Smtp SmtpSettings
// Rendering
ImagesDir string
CSVsDir string
RendererUrl string
RendererCallbackUrl string
RendererConcurrentRequestLimit int
// Security
DisableInitAdminCreation bool
DisableBruteForceLoginProtection bool
CookieSecure bool
CookieSameSiteDisabled bool
CookieSameSiteMode http.SameSite
AllowEmbedding bool
XSSProtectionHeader bool
ContentTypeProtectionHeader bool
StrictTransportSecurity bool
StrictTransportSecurityMaxAge int
StrictTransportSecurityPreload bool
StrictTransportSecuritySubDomains bool
// CSPEnabled toggles Content Security Policy support.
CSPEnabled bool
// CSPTemplate contains the Content Security Policy template.
CSPTemplate string
TempDataLifetime time.Duration
PluginsEnableAlpha bool
PluginsAppsSkipVerifyTLS bool
PluginSettings PluginSettings
PluginsAllowUnsigned []string
PluginCatalogURL string
PluginCatalogHiddenPlugins []string
PluginAdminEnabled bool
PluginAdminExternalManageEnabled bool
DisableSanitizeHtml bool
EnterpriseLicensePath string
// Metrics
MetricsEndpointEnabled bool
MetricsEndpointBasicAuthUsername string
MetricsEndpointBasicAuthPassword string
MetricsEndpointDisableTotalStats bool
MetricsGrafanaEnvironmentInfo map[string]string
// Dashboards
DefaultHomeDashboardPath string
// Auth
LoginCookieName string
LoginMaxInactiveLifetime time.Duration
LoginMaxLifetime time.Duration
TokenRotationIntervalMinutes int
SigV4AuthEnabled bool
BasicAuthEnabled bool
AdminUser string
AdminPassword string
// AWS Plugin Auth
AWSAllowedAuthProviders []string
AWSAssumeRoleEnabled bool
AWSListMetricsPageLimit int
// Azure Cloud settings
Azure AzureSettings
// Auth proxy settings
AuthProxyEnabled bool
AuthProxyHeaderName string
AuthProxyHeaderProperty string
AuthProxyAutoSignUp bool
AuthProxyEnableLoginToken bool
AuthProxyWhitelist string
AuthProxyHeaders map[string]string
AuthProxySyncTTL int
// OAuth
OAuthCookieMaxAge int
// JWT Auth
JWTAuthEnabled bool
JWTAuthHeaderName string
JWTAuthEmailClaim string
JWTAuthUsernameClaim string
JWTAuthExpectClaims string
JWTAuthJWKSetURL string
JWTAuthCacheTTL time.Duration
JWTAuthKeyFile string
JWTAuthJWKSetFile string
// Dataproxy
SendUserHeader bool
DataProxyLogging bool
DataProxyTimeout int
DataProxyDialTimeout int
DataProxyTLSHandshakeTimeout int
DataProxyExpectContinueTimeout int
DataProxyMaxConnsPerHost int
DataProxyMaxIdleConns int
DataProxyKeepAlive int
DataProxyIdleConnTimeout int
ResponseLimit int64
DataProxyRowLimit int64
// DistributedCache
RemoteCacheOptions *RemoteCacheOptions
EditorsCanAdmin bool
ApiKeyMaxSecondsToLive int64
// Use to enable new features which may still be in alpha/beta stage.
FeatureToggles map[string]bool
AnonymousEnabled bool
AnonymousOrgName string
AnonymousOrgRole string
AnonymousHideVersion bool
DateFormats DateFormats
// User
UserInviteMaxLifetime time.Duration
HiddenUsers map[string]struct{}
// Annotations
AnnotationCleanupJobBatchSize int64
AlertingAnnotationCleanupSetting AnnotationCleanupSettings
DashboardAnnotationCleanupSettings AnnotationCleanupSettings
APIAnnotationCleanupSettings AnnotationCleanupSettings
// Sentry config
Sentry Sentry
// Data sources
DataSourceLimit int
// Snapshots
SnapshotPublicMode bool
ErrTemplateName string
Env string
// Analytics
CheckForUpdates bool
ReportingDistributor string
ReportingEnabled bool
ApplicationInsightsConnectionString string
ApplicationInsightsEndpointUrl string
// LDAP
LDAPEnabled bool
LDAPAllowSignup bool
Quota QuotaSettings
DefaultTheme string
HomePage string
AutoAssignOrg bool
AutoAssignOrgId int
AutoAssignOrgRole string
// ExpressionsEnabled specifies whether expressions are enabled.
ExpressionsEnabled bool
ImageUploadProvider string
// LiveMaxConnections is a maximum number of WebSocket connections to
// Grafana Live ws endpoint (per Grafana server instance). 0 disables
// Live, -1 means unlimited connections.
LiveMaxConnections int
// LiveHAEngine is a type of engine to use to achieve HA with Grafana Live.
// Zero value means in-memory single node setup.
LiveHAEngine string
// LiveHAEngineAddress is a connection address for Live HA engine.
LiveHAEngineAddress string
// LiveAllowedOrigins is a set of origins accepted by Live. If not provided
// then Live uses AppURL as the only allowed origin.
LiveAllowedOrigins []string
// Grafana.com URL
GrafanaComURL string
// AlertingBaseInterval controls the alerting base interval in seconds.
// Only for internal use and not user configuration.
AlertingBaseInterval time.Duration
// Geomap base layer config
GeomapDefaultBaseLayerConfig map[string]interface{}
GeomapEnableCustomBaseLayers bool
// Unified Alerting
UnifiedAlerting UnifiedAlertingSettings
}
TODO move all global vars to this struct
func NewCfgFromArgs ¶
func NewCfgFromArgs(args CommandLineArgs) (*Cfg, error)
func (*Cfg) GetContentDeliveryURL ¶
GetContentDeliveryURL returns full content delivery URL with /<edition>/<version> added to URL
func (Cfg) IsDatabaseMetricsEnabled ¶
IsDatabaseMetricsEnabled returns whether the database instrumentation feature is enabled.
func (Cfg) IsHTTPRequestHistogramDisabled ¶
IsHTTPRequestHistogramDisabled returns whether the request historgrams is disabled. This feature toggle will be removed in Grafana 8.x but gives the operator some graceperiod to update all the monitoring tools.
func (Cfg) IsLiveConfigEnabled ¶
IsLiveConfigEnabled returns true if live should be able to save configs to SQL tables
func (Cfg) IsNewNavigationEnabled ¶
func (Cfg) IsTrimDefaultsEnabled ¶
IsTrimDefaultsEnabled returns whether the standalone trim dashboard default feature is enabled.
func (*Cfg) Load ¶
func (cfg *Cfg) Load(args CommandLineArgs) error
func (*Cfg) LogConfigSources ¶
func (cfg *Cfg) LogConfigSources()
func (*Cfg) ReadUnifiedAlertingSettings ¶
ReadUnifiedAlertingSettings reads both the `unified_alerting` and `alerting` sections of the configuration while preferring configuration the `alerting` section. It first reads the `unified_alerting` section, then looks for non-defaults on the `alerting` section and prefers those.
func (*Cfg) SectionWithEnvOverrides ¶
func (cfg *Cfg) SectionWithEnvOverrides(s string) *DynamicSection
SectionWithEnvOverrides dynamically overrides keys with environment variables. As a side effect, the value of the setting key will be updated if an environment variable is present.
type CommandLineArgs ¶
type DateFormatIntervals ¶
type DateFormats ¶
type DateFormats struct {
FullDate string `json:"fullDate"`
UseBrowserLocale bool `json:"useBrowserLocale"`
Interval DateFormatIntervals `json:"interval"`
DefaultTimezone string `json:"defaultTimezone"`
DefaultWeekStart string `json:"defaultWeekStart"`
}
type DynamicSection ¶
func (*DynamicSection) Key ¶
func (s *DynamicSection) Key(k string) *ini.Key
Key dynamically overrides keys with environment variables. As a side effect, the value of the setting key will be updated if an environment variable is present.
type GlobalQuota ¶
type KeyValue ¶
type KeyValue interface {
// Key returns pair's key.
Key() string
// Value returns pair's value.
Value() string
// MustString returns the value's string representation
// If empty, then it returns the given default.
MustString(defaultVal string) string
// MustBool returns the value's boolean representation
// Otherwise returns the given default.
MustBool(defaultVal bool) bool
// MustDuration returns the value's time.Duration
// representation. Otherwise returns the given default.
MustDuration(defaultVal time.Duration) time.Duration
}
KeyValue represents a settings key-value for a given pair of section and key.
type OSSImpl ¶
type OSSImpl struct {
Cfg *Cfg
}
func ProvideProvider ¶
func (OSSImpl) Current ¶
func (o OSSImpl) Current() SettingsBag
func (OSSImpl) IsFeatureToggleEnabled ¶
func (OSSImpl) RegisterReloadHandler ¶
func (OSSImpl) RegisterReloadHandler(string, ReloadHandler)
func (OSSImpl) Update ¶
func (OSSImpl) Update(SettingsBag, SettingsRemovals) error
type OrgQuota ¶
type PluginSettings ¶
PluginSettings maps plugin id to map of key/value settings.
type Provider ¶
type Provider interface {
// Current returns a SettingsBag with a static copy of
// the current configured pairs of key/values for each
// configuration section.
Current() SettingsBag
// Update receives a SettingsBag with the pairs of key/values
// to be updated per section and a SettingsRemovals with the
// section keys to be removed.
Update(updates SettingsBag, removals SettingsRemovals) error
// KeyValue returns a key-value abstraction
// for the given pair of section and key.
KeyValue(section, key string) KeyValue
// Section returns a settings section
// abstraction for the given section name.
Section(section string) Section
// RegisterReloadHandler registers a handler for validation and reload
// of configuration updates tied to a specific section
RegisterReloadHandler(section string, handler ReloadHandler)
// IsFeatureToggleEnabled checks if the feature's toggle is enabled
IsFeatureToggleEnabled(name string) bool
}
Provider is a settings provider abstraction with thread-safety and runtime updates.
type QuotaSettings ¶
type QuotaSettings struct {
Enabled bool
Org *OrgQuota
User *UserQuota
Global *GlobalQuota
}
type ReloadHandler ¶
type ReloadHandler interface {
// Reload handles reloading of configuration changes.
Reload(section Section) error
// Validate validates the configuration, if the validation
// fails the configuration will not be updated neither reloaded.
Validate(section Section) error
}
ReloadHandler defines the expected behaviour from a service that have support for configuration reloads.
type RemoteCacheOptions ¶
type Section ¶
type Section interface {
// KeyValue returns a key-value
// abstraction for the given key.
KeyValue(key string) KeyValue
}
Section is a settings section copy with all of its pairs of keys-values.
type SettingsBag ¶
type SettingsRemovals ¶
type SmtpSettings ¶
type UnifiedAlertingSettings ¶
type UnifiedAlertingSettings struct {
AdminConfigPollInterval time.Duration
AlertmanagerConfigPollInterval time.Duration
HAListenAddr string
HAAdvertiseAddr string
HAPeers []string
HAPeerTimeout time.Duration
HAGossipInterval time.Duration
HAPushPullInterval time.Duration
MaxAttempts int64
MinInterval time.Duration
EvaluationTimeout time.Duration
ExecuteAlerts bool
DefaultConfiguration string
Enabled bool
DisabledOrgs map[int64]struct{}
}
type ValidationError ¶
type ValidationError struct {
Errors []error
}
func (ValidationError) Error ¶
func (v ValidationError) Error() string