profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/gotjosh/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
gotjosh gotjosh @grafana London, UK pixelpt.com I hate computers, they hate me back - It's complicated.

gotjosh/dotfiles 4

My dotfiles

gotjosh/dependabot-core 2

The clever bit of Dependabot

gotjosh/alertmanager 1

Prometheus Alertmanager

gotjosh/cortex 1

A horizontally scalable, highly available, multi-tenant, long term Prometheus.

codesome/cortex 0

A multitenant, horizontally scalable Prometheus as a Service

cored/broadway 0

Broadway

cored/levelup 0

Leveling Up Engineering Skills

gotjosh/administrate 0

A Rails engine that helps you put together a super-flexible admin dashboard.

gotjosh/administrate-field-image 0

Official Image field plugin for Administrate

gotjosh/agent 0

A lightweight subset of Prometheus for Grafana Cloud.

PullRequestReviewEvent

Pull request review commentgrafana/grafana

Alerting: Move alertmanager default config to UnifiedAlertingSettings

 func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error { 			uaCfg.HAPeers = append(uaCfg.HAPeers, peer) 		} 	}+	//TODO load from ini file
	// TODO load from ini file
yuri-tceretian

comment created time in 2 days

Pull request review commentgrafana/grafana

Alerting template functions

 The following template variables are available when expanding annotations and la | $values | The values of all reduce and math expressions that were evaluated for this alert rule. For example, `{{ $values.A }}`, `{{ $values.A.Labels }}` and `{{ $values.A.Value }}` where `A` is the `refID` of the expression. This is unavailable when the rule uses a classic condition. | | $value  | The value string of the alert instance. For example, `[ var='A' labels={instance=foo} value=10 ]`.                                                                                                                                                                                  | +#### Template functions

That works for me.

santihernandezc

comment created time in 2 days

PullRequestReviewEvent

push eventgrafana/grafana

Grot (@grafanabot)

commit sha 4ffa29d959aa9fbb856c4fa6cf74c6fb713f4c2e

Fix alerts with evaluation interval more than 30 seconds resolving in Alertmanager (#39513) (#39523) (cherry picked from commit 27609dc2c57970f7228ce3c34cebc9c6dd6b9f5c) Co-authored-by: George Robinson <george.robinson@grafana.com>

view details

push time in 2 days

delete branch grafana/grafana

delete branch : backport-39513-to-v8.2.x

delete time in 2 days

PR merged grafana/grafana

Reviewers
[v8.2.x] Alerting: Fix alerts with evaluation interval more than 30 seconds resolving before notification area/backend backport

Backport 27609dc2c57970f7228ce3c34cebc9c6dd6b9f5c from #39513

+5 -5

0 comment

2 changed files

grafanabot

pr closed time in 2 days

pull request commentgrafana/grafana

Encryption: Refactor securejsondata.SecureJsonData to stop relying on global functions

I'll add it to our backlog so that we can take a look - I haven't looked at this PR in-depth but worth posing the question now:

  • Have we consider how this would work with our migration? Or would this no affect that?
joanlopez

comment created time in 2 days

issue closedgrafana/grafana

Alertmanager API not deleting silences

<!-- Please use this template to create your bug report. By providing as much info as possible you help us understand the issue, reproduce it and resolve it for you quicker. Therefor take a couple of extra minutes to make sure you have provided all info needed.

PROTIP: record your screen and attach it as a gif to showcase the issue.

  • Questions should be posted to: https://community.grafana.com
  • Use query inspector to troubleshoot issues: https://bit.ly/2XNF6YS
  • How to record and attach gif: https://bit.ly/2Mi8T6K -->

What happened: Trying to remove a silenced alert via the API

What you expected to happen: Alert to be unsilenced and for alerts to start being sent again.

How to reproduce it (as minimally and precisely as possible): Do a get request of your silences: /api/alertmanager/grafana/api/v2/silences/ Select one ID from the output:

[
    {
        "id": "9ae17ed1-7086-4d87-8a5f-ffb8618ed6f1",
        "status": {
            "state": "active"
        },
        "updatedAt": "2021-09-17T18:20:10.526Z",

Do a delete request using that id in the URL: /api/alertmanager/grafana/api/v2/silences/9ae17ed1-7086-4d87-8a5f-ffb8618ed6f1

returns: 404

{
    "message": "Not found"
}

Anything else we need to know?: Doing: /api/alertmanager/grafana/api/v2/silences/9ae17ed1-7086-4d87-8a5f-ffb8618ed6f1 on a get request will also produce the same error.

As per the spec, this should be correct: https://editor.swagger.io/?url=https://raw.githubusercontent.com/grafana/grafana/main/pkg/services/ngalert/api/tooling/post.json

Environment: Docker

  • Grafana version: v8.1.3 (a61f38238c)
  • Data source type & version: Prometheus
  • OS Grafana is installed on: Docker build
  • User OS & Browser: macOS Catalina, Chrome (latest)
  • Grafana plugins: boomtable
  • Others:

closed time in 2 days

tom0010

issue commentgrafana/grafana

Alertmanager API not deleting silences

The URL appears to be incorrect, it should be /api/alertmanager/grafana/api/v2/silence/9ae17ed1-7086-4d87-8a5f-ffb8618ed6f1 Where silence is without the S.

You can see the route definition in https://github.com/grafana/grafana/blob/dfbd7bf64fd4d0af06627924c79bc7ed9464ece9/pkg/services/ngalert/api/generated_base_api_alertmanager.go#L59

tom0010

comment created time in 2 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentgrafana/grafana

Alerting template functions

 The following template variables are available when expanding annotations and la | $values | The values of all reduce and math expressions that were evaluated for this alert rule. For example, `{{ $values.A }}`, `{{ $values.A.Labels }}` and `{{ $values.A.Value }}` where `A` is the `refID` of the expression. This is unavailable when the rule uses a classic condition. | | $value  | The value string of the alert instance. For example, `[ var='A' labels={instance=foo} value=10 ]`.                                                                                                                                                                                  | +#### Template functions

How do you feel about including a list of all the function and explicitly saying which ones we don't support? You can add a new column that reads - "supported" and includes the version in which they were introduced or "No" if we don't support them.

santihernandezc

comment created time in 3 days

Pull request review commentgrafana/grafana

Alerting template functions

 require ( 	go.uber.org/atomic v1.9.0 // indirect

Have we merged from main? I reckon these shouldn't be here if we already bumped the dependencies.

santihernandezc

comment created time in 3 days

Pull request review commentgrafana/grafana

Alerting template functions

+package state++import (+	"errors"+	"testing"++	"github.com/grafana/grafana-plugin-sdk-go/data"+	"github.com/grafana/grafana/pkg/services/ngalert/eval"+	"github.com/stretchr/testify/assert"+	"github.com/stretchr/testify/require"+	ptr "github.com/xorcare/pointer"+)++func TestTemplateCaptureValueStringer(t *testing.T) {+	cases := []struct {+		name     string+		value    templateCaptureValue+		expected string+	}{{+		name:     "0 is returned as integer value",+		value:    templateCaptureValue{Value: 0},+		expected: "0",+	}, {+		name:     "1.0 is returned as integer value",+		value:    templateCaptureValue{Value: 1.0},+		expected: "1",+	}, {+		name:     "1.1 is returned as decimal value",+		value:    templateCaptureValue{Value: 1.1},+		expected: "1.1",+	}}++	for _, c := range cases {+		t.Run(c.name, func(t *testing.T) {+			assert.Equal(t, c.expected, c.value.String())+		})+	}+}++func TestExpandTemplate(t *testing.T) {

Are we missing cases for the functions we don't support? I'd like us to test against everything even if their return value is "".

santihernandezc

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

push eventgrafana/grafana

George Robinson

commit sha 27609dc2c57970f7228ce3c34cebc9c6dd6b9f5c

Fix alerts with evaluation interval more than 30 seconds resolving in Alertmanager (#39513)

view details

push time in 3 days

PR merged grafana/grafana

Reviewers
Alerting: Fix alerts with evaluation interval more than 30 seconds resolving before notification type/bug area/backend add to changelog backport v8.1.x backport v8.2.x

What this PR does / why we need it:

This PR fixes a bug introduced in #38648 that is causing some users of Grafana to not receive notifications for firing alerts.

Which issue(s) this PR fixes:

#39295

Special notes for your reviewer:

+5 -5

0 comment

2 changed files

gerobinson

pr closed time in 3 days

PullRequestReviewEvent

Pull request review commentgrafana/grafana

Alerting: Optimization of fetching data in multiorg alertmanager

 func (moa *MultiOrgAlertmanager) LoadAndSyncAlertmanagersForOrgs(ctx context.Con  	// Then, sync them by creating or deleting Alertmanagers as necessary. 	moa.metrics.DiscoveredConfigurations.Set(float64(len(orgIDs)))-	moa.SyncAlertmanagersForOrgs(orgIDs)+	moa.SyncAlertmanagersForOrgs(ctx, orgIDs)  	moa.logger.Debug("done synchronizing Alertmanagers for orgs")  	return nil } -func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(orgIDs []int64) {+// getLatestConfigs retrieves the latest Alertmanager configuration for every organization. It returns a map where the key is the ID of each organization and the value is the configuration.+func (moa *MultiOrgAlertmanager) getLatestConfigs(ctx context.Context) (map[int64]*models.AlertConfiguration, error) {+	configs, err := moa.configStore.GetAllLatestAlertmanagerConfiguration(ctx)+	if err != nil {+		return nil, err+	}++	result := make(map[int64]*models.AlertConfiguration, len(configs))+	for _, config := range configs {+		result[config.OrgID] = config+	}++	return result, nil+}++func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(ctx context.Context, orgIDs []int64) {
// SyncAlertmanagersForOrgs syncs configuration of the Alertmanager required by each organization.
func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(ctx context.Context, orgIDs []int64) {
yuri-tceretian

comment created time in 4 days

Pull request review commentgrafana/grafana

Alerting: Optimization of fetching data in multiorg alertmanager

 func (am *Alertmanager) SaveAndApplyConfig(cfg *apimodels.PostableUserConfig) er 	return nil } -// SyncAndApplyConfigFromDatabase picks the latest config from database and restarts-// the components with the new config.-func (am *Alertmanager) SyncAndApplyConfigFromDatabase() error {-	am.reloadConfigMtx.Lock()-	defer am.reloadConfigMtx.Unlock()--	// First, let's get the configuration we need from the database.-	q := &ngmodels.GetLatestAlertmanagerConfigurationQuery{OrgID: am.orgID}-	if err := am.Store.GetLatestAlertmanagerConfiguration(q); err != nil {-		// If there's no configuration in the database, let's use the default configuration.-		if errors.Is(err, store.ErrNoAlertmanagerConfiguration) {-			// First, let's save it to the database. We don't need to use a transaction here as we'll always succeed.-			am.logger.Info("no Alertmanager configuration found, saving and applying a default")-			savecmd := &ngmodels.SaveAlertmanagerConfigurationCmd{-				AlertmanagerConfiguration: alertmanagerDefaultConfiguration,-				Default:                   true,-				ConfigurationVersion:      fmt.Sprintf("v%d", ngmodels.AlertConfigurationVersion),-				OrgID:                     am.orgID,-			}-			if err := am.Store.SaveAlertmanagerConfiguration(savecmd); err != nil {-				return err-			}--			q.Result = &ngmodels.AlertConfiguration{AlertmanagerConfiguration: alertmanagerDefaultConfiguration, Default: true}-		} else {-			return fmt.Errorf("unable to get Alertmanager configuration from the database: %w", err)-		}-	}--	cfg, err := Load([]byte(q.Result.AlertmanagerConfiguration))+//ApplyConfig applies the configuration to the Alertmanager
// ApplyConfig applies the configuration to the Alertmanager.
yuri-tceretian

comment created time in 4 days

Pull request review commentgrafana/grafana

Alerting: Optimization of fetching data in multiorg alertmanager

 func (moa *MultiOrgAlertmanager) SyncAlertmanagersForOrgs(orgIDs []int64) { 			if err != nil { 				moa.logger.Error("unable to create Alertmanager for org", "org", orgID, "err", err) 			}-			moa.alertmanagers[orgID] = am-			existing = am+			alertmanager = am 		} -		//TODO: This will create an N+1 query-		if err := existing.SyncAndApplyConfigFromDatabase(); err != nil {-			moa.logger.Error("failed to apply Alertmanager config for org", "org", orgID, "err", err)+		dbConfig, cfgFound := dbConfigs[orgID]+		if !cfgFound {+			if found {+				//This means that the configuration is gone but the organization as well as the Alertmanager exists
				// This means that the configuration is gone but the organization, as well as the Alertmanager, exists.
yuri-tceretian

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentgrafana/grafana

Alerting template functions

 The following template variables are available when expanding annotations and la | $values | The values of all reduce and math expressions that were evaluated for this alert rule. For example, `{{ $values.A }}`, `{{ $values.A.Labels }}` and `{{ $values.A.Value }}` where `A` is the `refID` of the expression. This is unavailable when the rule uses a classic condition. | | $value  | The value string of the alert instance. For example, `[ var='A' labels={instance=foo} value=10 ]`.                                                                                                                                                                                  | +#### Template functions++The following template functions are available when expanding annotations and labels.++| Name               | Argument         | Return                 | Description                                                                                                                        |+| ------------------ | ---------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |+| humanize           | number or string | string                 | Converts a number to a more readable format, using metric prefixes.                                                                |

pathPrefix and externalURL

I think we can fix those, grafana has a setting that exposes the external URL of the instance - I think we should use those.

graphLink and tableLink work as expected, but we have to check with FE team whether or not the links provided by Prometheus' functions match our links for graphs and tables.

Then, let's align with them and check to make sure they work as expected.

santihernandezc

comment created time in 5 days

push eventgrafana/grafana

gotjosh

commit sha fcbcfd232b59228b086d7d0b5a9e36d119523485

Alerting: Move spammy log line to debug in the state manager (#39410)

view details

push time in 5 days