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.
Expose prometheus agent sharding strategy (#1605)
* Expose prometheus agent sharding strategy Signed-off-by: QuentinBisson <[email protected]> * Update main.go Co-authored-by: Marie Roque <[email protected]> * Update service/controller/resource/monitoring/remotewriteconfig/types.go Co-authored-by: Marie Roque <[email protected]> Signed-off-by: QuentinBisson <[email protected]> * fix: add missing or in helm chart Signed-off-by: QuentinBisson <[email protected]> --------- Signed-off-by: QuentinBisson <[email protected]> Co-authored-by: Marie Roque <[email protected]>
- Loading branch information
1 parent
797429d
commit 200c0e0
Showing
15 changed files
with
114 additions
and
56 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
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
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
28 changes: 0 additions & 28 deletions
28
service/controller/resource/monitoring/remotewriteconfig/shards.go
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
service/controller/resource/monitoring/remotewriteconfig/types.go
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,30 @@ | ||
package remotewriteconfig | ||
|
||
import "math" | ||
|
||
type PrometheusAgentShardingStrategy struct { | ||
// Configures the number of series needed to add a new shard. Computation is number of series / ShardScaleUpSeriesCount | ||
ShardScaleUpSeriesCount float64 | ||
// Percentage of needed series based on ShardScaleUpSeriesCount to scale down agents | ||
ShardScaleDownPercentage float64 | ||
} | ||
|
||
// We want to start with 1 prometheus-agent for each 1M time series with a scale down 20% threshold. | ||
func (pass PrometheusAgentShardingStrategy) ComputeShards(currentShardCount int, timeSeries float64) int { | ||
shardScaleDownThreshold := pass.ShardScaleDownPercentage * pass.ShardScaleUpSeriesCount | ||
desiredShardCount := int(math.Ceil(timeSeries / pass.ShardScaleUpSeriesCount)) | ||
|
||
// 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.ShardScaleUpSeriesCount) > pass.ShardScaleUpSeriesCount-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