generated from giantswarm/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configure prometheus agent sharding per cluster (#1610)
* feat: configure prometheus agent sharding per cluster * Update CHANGELOG.md Co-authored-by: Hervé Nicol <[email protected]> * Document sharding overrides/ * Update README.md Co-authored-by: Hervé Nicol <[email protected]> * Update README.md Co-authored-by: Hervé Nicol <[email protected]> --------- Co-authored-by: Hervé Nicol <[email protected]>
- Loading branch information
1 parent
efb976b
commit 4841448
Showing
12 changed files
with
125 additions
and
53 deletions.
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,46 @@ | ||
package agent | ||
|
||
import "math" | ||
|
||
type ShardingStrategy struct { | ||
// Configures the number of series needed to add a new shard. Computation is number of series / ScaleUpSeriesCount | ||
ScaleUpSeriesCount float64 | ||
// Percentage of needed series based on ScaleUpSeriesCount to scale down agents | ||
ScaleDownPercentage float64 | ||
} | ||
|
||
func (pass1 ShardingStrategy) Merge(pass2 *ShardingStrategy) ShardingStrategy { | ||
strategy := ShardingStrategy{ | ||
pass1.ScaleUpSeriesCount, | ||
pass1.ScaleDownPercentage, | ||
} | ||
if pass2 != nil { | ||
if pass2.ScaleUpSeriesCount > 0 { | ||
strategy.ScaleUpSeriesCount = pass2.ScaleUpSeriesCount | ||
} | ||
if pass2.ScaleDownPercentage > 0 { | ||
strategy.ScaleDownPercentage = pass2.ScaleDownPercentage | ||
} | ||
} | ||
return strategy | ||
} | ||
|
||
// We want to start with 1 prometheus-agent for each 1M time series with a scale down 20% threshold. | ||
func (pass ShardingStrategy) ComputeShards(currentShardCount int, timeSeries float64) int { | ||
shardScaleDownThreshold := pass.ScaleDownPercentage * pass.ScaleUpSeriesCount | ||
desiredShardCount := int(math.Ceil(timeSeries / pass.ScaleUpSeriesCount)) | ||
|
||
// Compute Scale Down | ||
if currentShardCount > desiredShardCount { | ||
// We get the rest of a division of timeSeries by shardStep and we compare it with the scale down threshold | ||
if math.Mod(timeSeries, pass.ScaleUpSeriesCount) > pass.ScaleUpSeriesCount-shardScaleDownThreshold { | ||
desiredShardCount = currentShardCount | ||
} | ||
} | ||
|
||
// We always have a minimum of 1 agent, even if there is no worker node | ||
if desiredShardCount <= 0 { | ||
return 1 | ||
} | ||
return desiredShardCount | ||
} |
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
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
30 changes: 0 additions & 30 deletions
30
service/controller/resource/monitoring/remotewriteconfig/types.go
This file was deleted.
Oops, something went wrong.
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