Ver Fonte

fix: pass companyID to mkAlert so each loadgen uses its own company; set dedupe-pct=0

Luis Rosales há 1 mês atrás
pai
commit
9c2dc03dd9
2 ficheiros alterados com 5 adições e 3 exclusões
  1. 2 0
      docker-compose.yml
  2. 3 3
      loadgen/cmd/grpc/main.go

+ 2 - 0
docker-compose.yml

@@ -413,6 +413,7 @@ services:
       - --api-key=acme-001:acme-001-prom:s3cret-acme-001
       - --rate=5000
       - --workers=8
+      - --dedupe-pct=0
       - --duration=15m
       - --metrics=:8892
       - --instance=loadgen-grpc-1
@@ -429,6 +430,7 @@ services:
       - --api-key=acme-002:acme-002-prom:s3cret-acme-002
       - --rate=5000
       - --workers=8
+      - --dedupe-pct=0
       - --duration=15m
       - --metrics=:8892
       - --instance=loadgen-grpc-2

+ 3 - 3
loadgen/cmd/grpc/main.go

@@ -206,7 +206,7 @@ func runWorker(
 				close(ackCh)
 				return
 			case <-tickCh:
-				a := mkAlert("normal", sourceID, dedupePct, dedupeKey, payloadB)
+				a := mkAlert("normal", companyFromKey(apiKey), sourceID, dedupePct, dedupeKey, payloadB)
 				if err := stream.Send(prodCtx, alertToProto(companyFromKey(apiKey), sourceID, a)); err != nil {
 					// Check if it's a retriable error.
 					st, _ := status.FromError(err)
@@ -265,7 +265,7 @@ func companyFromKey(apiKey string) string {
 	return "acme-001"
 }
 
-func mkAlert(mode, sourceID string, dedupePct int, dedupeKey string, payloadB int) alert.Alert {
+func mkAlert(mode, companyID, sourceID string, dedupePct int, dedupeKey string, payloadB int) alert.Alert {
 	severity := pickSeverity(mode)
 	category := pickCategory(severity)
 	dk := ""
@@ -280,7 +280,7 @@ func mkAlert(mode, sourceID string, dedupePct int, dedupeKey string, payloadB in
 		"raw_msg": strings.Repeat("x", max(0, payloadB-64)),
 	}
 	return alert.Alert{
-		CompanyID: "acme-001",
+		CompanyID: companyID,
 		SourceID:  sourceID,
 		Severity:  severity,
 		Category:  category,