mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Short Links: Add setting for changing expiration time (#86003)
* Add setting for changing shortlink expiration time * Add docs, add better language * put all the numbers in the duration 🤷 * 🙄 * update language to be correct and clear * Add max limit and more documentation
This commit is contained in:
parent
cad9e23e54
commit
2247d6c415
@ -1422,6 +1422,11 @@ concurrent_query_limit =
|
||||
# Enable the Query history
|
||||
enabled = true
|
||||
|
||||
#################################### Short Links #############################
|
||||
[short_links]
|
||||
# Short links which are never accessed will be deleted as cleanup. Time is in days. Default is 7 days. Max is 365. 0 means they will be deleted approximately every 10 minutes.
|
||||
expire_time = 7
|
||||
|
||||
#################################### Internal Grafana Metrics ############
|
||||
# Metrics available at HTTP URL /metrics and /metrics/plugins/:pluginId
|
||||
[metrics]
|
||||
|
@ -137,7 +137,7 @@ Available in Grafana 7.3 and later versions.
|
||||
|
||||
The Share shortened link capability allows you to create smaller and simpler URLs of the format /goto/:uid instead of using longer URLs with query parameters. To create a shortened link to the executed query, click the **Share** option in the Explore toolbar.
|
||||
|
||||
A shortened link will automatically get deleted after seven (7) days from its creation if it's never used. If a link is used at least once, it won't ever get deleted.
|
||||
A shortened link that is not accessed will automatically get deleted after a [configurable period](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#short_links) (defaulting to seven days). If a link is used at least once, it won't be deleted.
|
||||
|
||||
### Sharing shortened links with absolute time
|
||||
|
||||
|
@ -1779,6 +1779,16 @@ Enable or disable the Query history. Default is `enabled`.
|
||||
|
||||
<hr>
|
||||
|
||||
## [short_links]
|
||||
|
||||
Configures settings around the short link feature.
|
||||
|
||||
### expire_time
|
||||
|
||||
Short links which are never accessed are considered expired or stale, and will be deleted as cleanup. Set the expiration time in days. Default is `7` days. Maximum is `365` days, and setting above the maximum will have `365` set instead. Setting `0` means the short links will be cleaned up approximately every 10 minutes.
|
||||
|
||||
<hr>
|
||||
|
||||
## [metrics]
|
||||
|
||||
For detailed instructions, refer to [Internal Grafana metrics]({{< relref "../set-up-grafana-monitoring" >}}).
|
||||
|
@ -257,7 +257,7 @@ func (srv *CleanUpService) expireOldVerifications(ctx context.Context) {
|
||||
func (srv *CleanUpService) deleteStaleShortURLs(ctx context.Context) {
|
||||
logger := srv.log.FromContext(ctx)
|
||||
cmd := shorturls.DeleteShortUrlCommand{
|
||||
OlderThan: time.Now().Add(-time.Hour * 24 * 7),
|
||||
OlderThan: time.Now().Add(-time.Duration(srv.Cfg.ShortLinkExpiration*24) * time.Hour),
|
||||
}
|
||||
if err := srv.ShortURLService.DeleteStaleShortURLs(ctx, &cmd); err != nil {
|
||||
logger.Error("Problem deleting stale short urls", "error", err.Error())
|
||||
|
@ -516,6 +516,9 @@ type Cfg struct {
|
||||
// Experimental scope settings
|
||||
ScopesListScopesURL string
|
||||
ScopesListDashboardsURL string
|
||||
|
||||
//Short Links
|
||||
ShortLinkExpiration int
|
||||
}
|
||||
|
||||
// AddChangePasswordLink returns if login form is disabled or not since
|
||||
@ -1158,6 +1161,14 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
|
||||
queryHistory := iniFile.Section("query_history")
|
||||
cfg.QueryHistoryEnabled = queryHistory.Key("enabled").MustBool(true)
|
||||
|
||||
shortLinks := iniFile.Section("short_links")
|
||||
cfg.ShortLinkExpiration = shortLinks.Key("expire_time").MustInt(7)
|
||||
|
||||
if cfg.ShortLinkExpiration > 365 {
|
||||
cfg.Logger.Warn("short_links expire_time must be less than 366 days. Setting to 365 days")
|
||||
cfg.ShortLinkExpiration = 365
|
||||
}
|
||||
|
||||
panelsSection := iniFile.Section("panels")
|
||||
cfg.DisableSanitizeHtml = panelsSection.Key("disable_sanitize_html").MustBool(false)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user