| 512 | } |
| 513 | |
| 514 | func newCompactor( |
| 515 | compactorCfg Config, |
| 516 | storageCfg cortex_tsdb.BlocksStorageConfig, |
| 517 | logger log.Logger, |
| 518 | registerer prometheus.Registerer, |
| 519 | bucketClientFactory func(ctx context.Context) (objstore.InstrumentedBucket, error), |
| 520 | blocksGrouperFactory BlocksGrouperFactory, |
| 521 | blocksCompactorFactory BlocksCompactorFactory, |
| 522 | blockDeletableCheckerFactory BlockDeletableCheckerFactory, |
| 523 | compactionLifecycleCallbackFactory CompactionLifecycleCallbackFactory, |
| 524 | limits *validation.Overrides, |
| 525 | ingestionReplicationFactor int, |
| 526 | ) (*Compactor, error) { |
| 527 | var compactorMetrics *compactorMetrics |
| 528 | if compactorCfg.ShardingStrategy == util.ShardingStrategyShuffle { |
| 529 | compactorMetrics = newCompactorMetrics(registerer) |
| 530 | } else { |
| 531 | compactorMetrics = newDefaultCompactorMetrics(registerer) |
| 532 | } |
| 533 | c := &Compactor{ |
| 534 | compactorCfg: compactorCfg, |
| 535 | storageCfg: storageCfg, |
| 536 | parentLogger: logger, |
| 537 | logger: log.With(logger, "component", "compactor"), |
| 538 | registerer: registerer, |
| 539 | bucketClientFactory: bucketClientFactory, |
| 540 | blocksGrouperFactory: blocksGrouperFactory, |
| 541 | blocksCompactorFactory: blocksCompactorFactory, |
| 542 | blockDeletableCheckerFactory: blockDeletableCheckerFactory, |
| 543 | compactionLifecycleCallbackFactory: compactionLifecycleCallbackFactory, |
| 544 | allowedTenants: users.NewAllowedTenants(compactorCfg.EnabledTenants, compactorCfg.DisabledTenants), |
| 545 | |
| 546 | CompactorStartDurationSeconds: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{ |
| 547 | Name: "cortex_compactor_start_duration_seconds", |
| 548 | Help: "Time in seconds spent by compactor running start function", |
| 549 | }), |
| 550 | CompactionRunsStarted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{ |
| 551 | Name: "cortex_compactor_runs_started_total", |
| 552 | Help: "Total number of compaction runs started.", |
| 553 | }), |
| 554 | CompactionRunsInterrupted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{ |
| 555 | Name: "cortex_compactor_runs_interrupted_total", |
| 556 | Help: "Total number of compaction runs interrupted.", |
| 557 | }), |
| 558 | CompactionRunsCompleted: promauto.With(registerer).NewCounter(prometheus.CounterOpts{ |
| 559 | Name: "cortex_compactor_runs_completed_total", |
| 560 | Help: "Total number of compaction runs successfully completed.", |
| 561 | }), |
| 562 | CompactionRunsFailed: promauto.With(registerer).NewCounter(prometheus.CounterOpts{ |
| 563 | Name: "cortex_compactor_runs_failed_total", |
| 564 | Help: "Total number of compaction runs failed.", |
| 565 | }), |
| 566 | CompactionRunsLastSuccess: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{ |
| 567 | Name: "cortex_compactor_last_successful_run_timestamp_seconds", |
| 568 | Help: "Unix timestamp of the last successful compaction run.", |
| 569 | }), |
| 570 | CompactionRunDiscoveredTenants: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{ |
| 571 | Name: "cortex_compactor_tenants_discovered", |