Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions receiver/awscontainerinsightreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type Config struct {
// EnableAcceleratedComputeMetrics enables features with accelerated compute resources where metrics are scraped from vendor specific sources
EnableAcceleratedComputeMetrics bool `mapstructure:"accelerated_compute_metrics"`

// AcceleratedComputeGPUMetricsCollectionInterval is the interval at which gpu metrics should be collected. The default is 60 second.
AcceleratedComputeGPUMetricsCollectionInterval time.Duration `mapstructure:"accelerated_compute_gpu_metrics_collection_interval"`

// KubeConfigPath is an optional attribute to override the default kube config path in an EC2 environment
KubeConfigPath string `mapstructure:"kube_config_path"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

const (
caFile = "/etc/amazon-cloudwatch-observability-agent-cert/tls-ca.crt"
collectionInterval = 60 * time.Second
jobName = "containerInsightsDCGMExporterScraper"
scraperMetricsPath = "/metrics"
scraperK8sServiceSelector = "k8s-app=dcgm-exporter-service"
Expand All @@ -30,7 +29,7 @@ type hostInfoProvider interface {
GetInstanceType() string
}

func GetScraperConfig(hostInfoProvider hostInfoProvider) *config.ScrapeConfig {
func GetScraperConfig(hostInfoProvider hostInfoProvider, collectionInterval time.Duration) *config.ScrapeConfig {
return &config.ScrapeConfig{
HTTPClientConfig: configutil.HTTPClientConfig{
TLSConfig: configutil.TLSConfig{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"strings"
"testing"
"time"

configutil "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand Down Expand Up @@ -165,7 +166,7 @@ func TestNewDcgmScraperEndToEnd(t *testing.T) {
Consumer: mConsumer,
Host: componenttest.NewNopHost(),
HostInfoProvider: mockHostInfoProvider{},
ScraperConfigs: GetScraperConfig(mockHostInfoProvider{}),
ScraperConfigs: GetScraperConfig(mockHostInfoProvider{}, 30*time.Second),
Logger: settings.Logger,
})
assert.NoError(t, err)
Expand Down Expand Up @@ -244,3 +245,13 @@ func TestDcgmScraperJobName(t *testing.T) {
// needs to start with containerInsights
assert.True(t, strings.HasPrefix(jobName, "containerInsightsDCGMExporterScraper"))
}

func TestGetScraperConfig(t *testing.T) {
hostInfoProvider := mockHostInfoProvider{}
customInterval := 30 * time.Second
config := GetScraperConfig(hostInfoProvider, customInterval)

// Verify the custom collection interval is used
assert.Equal(t, model.Duration(customInterval), config.ScrapeInterval)
assert.Equal(t, model.Duration(customInterval), config.ScrapeTimeout)
}
2 changes: 1 addition & 1 deletion receiver/awscontainerinsightreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (acir *awsContainerInsightReceiver) initDcgmScraper(ctx context.Context, ho
TelemetrySettings: acir.settings,
Consumer: &decoConsumer,
Host: host,
ScraperConfigs: gpu.GetScraperConfig(hostInfo),
ScraperConfigs: gpu.GetScraperConfig(hostInfo, acir.config.AcceleratedComputeGPUMetricsCollectionInterval),
HostInfoProvider: hostInfo,
Logger: acir.settings.Logger,
}
Expand Down
Loading