Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/purefa] Pure Storage FlashArray - Purity v6.6.11+ Native OpenMetrics Support #36251

Merged
merged 27 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e6e939f
enable namespaces
chrroberts-pure Nov 6, 2024
7ff2d28
Merge branch 'open-telemetry:main' into native_purefa
chrroberts-pure Nov 6, 2024
b86e73b
add namespace to config
chrroberts-pure Nov 6, 2024
3f9e36e
enable tls insecure for https scrapes
chrroberts-pure Nov 6, 2024
ff0c0e6
Create 36251-purefa-native-om-support.yaml
chrroberts-pure Nov 6, 2024
ef1ea5e
added namespace config and tls insecurity tests
chrroberts-pure Nov 7, 2024
99fe3e9
fix scraper test
chrroberts-pure Nov 7, 2024
cf6065e
Added Test for Scrape Protocols in Scraper
chrroberts-pure Nov 7, 2024
df32e1c
Merge branch 'main' into native_purefa
chrroberts-pure Nov 7, 2024
d42be01
correct scrape protocol
chrroberts-pure Nov 7, 2024
363b7b8
Merge branch 'native_purefa' of https://github.com/chrroberts-pure/op…
chrroberts-pure Nov 7, 2024
3fe7884
Merge branch 'main' into native_purefa
chrroberts-pure Nov 8, 2024
730a100
Merge branch 'open-telemetry:main' into native_purefa
chrroberts-pure Nov 25, 2024
6c880df
Update README.md
chrroberts-pure Nov 25, 2024
29e74e9
Merge branch 'main' into native_purefa
chrroberts-pure Nov 27, 2024
aa86063
Implement tlssettings strut maps
chrroberts-pure Nov 27, 2024
7662ade
Update scraper.go
chrroberts-pure Nov 27, 2024
03b98d3
Update factory.go
chrroberts-pure Nov 29, 2024
ce9db2c
Merge branch 'main' into native_purefa
chrroberts-pure Nov 29, 2024
2f506f1
go tidy
chrroberts-pure Dec 2, 2024
cefbb68
Merge branch 'main' into native_purefa
chrroberts-pure Dec 2, 2024
295b9d9
Merge branch 'main' into native_purefa
chrroberts-pure Dec 2, 2024
377d567
Update go.mod
chrroberts-pure Dec 2, 2024
96b2ecb
Merge branch 'main' into native_purefa
chrroberts-pure Dec 9, 2024
c052b55
update prom config
chrroberts-pure Dec 9, 2024
dd97a95
Merge branch 'main' into native_purefa
chrroberts-pure Dec 10, 2024
26fc945
Update go.mod
chrroberts-pure Dec 10, 2024
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
27 changes: 27 additions & 0 deletions .chloggen/36251-purefa-native-om-support.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: 'enhancement'

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: purefareceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Implements support for scraping Pure Storage FlashArray with Purity version 6.6.11+

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [36251]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
32 changes: 19 additions & 13 deletions receiver/purefareceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

The Pure Storage FlashArray receiver, receives metrics from Pure Storage internal services hosts.
The Pure Storage FlashArray receiver, receives metrics from the Pure Storage FlashArray.

## Configuration

The following settings are required:
- `endpoint` (default: `http://172.0.0.0:9490/metrics/array`): The URL of the scraper selected endpoint
- `endpoint` (default: `http://127.0.0.0:9490/metrics/array`): The URL of the scraper selected endpoint.
- `fa_array_name` (no default): The array's pretty name to be used as a metrics label.
jpkrohling marked this conversation as resolved.
Show resolved Hide resolved
- `namespace` (default:purefa): The selected Pure Storage OpenMetrics Namespace to query.

In the below examples array01 is using the [Pure Storage FlashArray OpenMetrics exporter](https://github.com/PureStorage-OpenConnect/pure-fa-openmetrics-exporter), while array02 is using the native on-box metrics provided in Purity//FA v6.6.11+.

Example:

Expand Down Expand Up @@ -55,15 +59,17 @@ receivers:
env: dev
settings:
reload_intervals:
array: 10s
hosts: 13s
directories: 15s
pods: 30s
volumes: 25s
array: 20s
hosts: 60s
directories: 60s
pods: 60s
volumes: 60s

purefa/array02:
fa_array_name: foobar02
endpoint: http://127.0.0.1:9490/metrics
endpoint: https://127.0.0.1/metrics
chrroberts-pure marked this conversation as resolved.
Show resolved Hide resolved
tls:
insecure_skip_verify: true
array:
- address: array02
auth:
Expand All @@ -87,11 +93,11 @@ receivers:
env: production
settings:
reload_intervals:
array: 15s
hosts: 15s
directories: 15s
pods: 30s
volumes: 25s
array: 20s
hosts: 60s
directories: 60s
pods: 60s
volumes: 60s

service:
extensions: [bearertokenauth/array01,bearertokenauth/array02]
Expand Down
8 changes: 7 additions & 1 deletion receiver/purefareceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ type Config struct {
// Env represents the respective environment value valid to scrape
Env string `mapstructure:"env"`

// ArrayName represents the display name that is appended to the received metrics, as the `host` label if not provided by OpenMetrics output, and to the `fa_array_name` label always.
// ArrayName represents the display name that is appended to the received metrics, as the `host` label if not provided by OpenMetrics output, and to the `fa_array_name` label always
ArrayName string `mapstructure:"fa_array_name"`

// Namespace selects the OpenMetrics namespace requested
Namespace string `mapstructure:"namespace"`
}

type Settings struct {
Expand All @@ -63,6 +66,9 @@ func (c *Config) Validate() error {
if c.ArrayName == "" {
errs = multierr.Append(errs, errors.New("the array's pretty name as 'fa_array_name' must be provided"))
}
if c.Namespace == "" {
errs = multierr.Append(errs, errors.New("a specified namespace must be provided"))
}
if c.Settings.ReloadIntervals.Array == 0 {
errs = multierr.Append(errs, errors.New("reload interval for 'array' must be provided"))
}
Expand Down
11 changes: 6 additions & 5 deletions receiver/purefareceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ func TestLoadConfig(t *testing.T) {
expected: &Config{
ClientConfig: clientConfig,
ArrayName: "foobar.example.com",
Namespace: "purefa",
Settings: &Settings{
ReloadIntervals: &ReloadIntervals{
Array: 15 * time.Second,
Hosts: 15 * time.Second,
Directories: 15 * time.Second,
Pods: 15 * time.Second,
Volumes: 15 * time.Second,
Array: 60 * time.Second,
Hosts: 60 * time.Second,
Directories: 60 * time.Second,
Pods: 60 * time.Second,
Volumes: 60 * time.Second,
},
},
},
Expand Down
13 changes: 7 additions & 6 deletions receiver/purefareceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ func NewFactory() receiver.Factory {
func createDefaultConfig() component.Config {
return &Config{
ArrayName: "foobar.example.com",
ClientConfig: confighttp.NewDefaultClientConfig(),
Namespace: "purefa",
ClientConfig: confighttp.NewDefaultClientConfig(),
Settings: &Settings{
ReloadIntervals: &ReloadIntervals{
Array: 15 * time.Second,
Hosts: 15 * time.Second,
Directories: 15 * time.Second,
Pods: 15 * time.Second,
Volumes: 15 * time.Second,
Array: 60 * time.Second,
Hosts: 60 * time.Second,
Directories: 60 * time.Second,
Pods: 60 * time.Second,
Volumes: 60 * time.Second,
},
},
}
Expand Down
31 changes: 20 additions & 11 deletions receiver/purefareceiver/internal/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,32 @@ const (
)

type scraper struct {
scraperType ScraperType
endpoint string
configs []ScraperConfig
scrapeInterval time.Duration
labels model.LabelSet
scraperType ScraperType
endpoint string
namespace string
insecureskipverify bool
configs []ScraperConfig
scrapeInterval time.Duration
labels model.LabelSet
}

func NewScraper(_ context.Context,
scraperType ScraperType,
endpoint string,
namespace string,
insecureskipverify bool,
configs []ScraperConfig,
scrapeInterval time.Duration,
labels model.LabelSet,
) Scraper {
return &scraper{
scraperType: scraperType,
endpoint: endpoint,
configs: configs,
scrapeInterval: scrapeInterval,
labels: labels,
scraperType: scraperType,
endpoint: endpoint,
namespace: namespace,
insecureskipverify: insecureskipverify,
configs: configs,
scrapeInterval: scrapeInterval,
labels: labels,
}
}

Expand All @@ -71,17 +77,20 @@ func (h *scraper) ToPrometheusReceiverConfig(host component.Host, _ receiver.Fac

httpConfig := configutil.HTTPClientConfig{}
httpConfig.BearerToken = configutil.Secret(bearerToken)
httpConfig.TLSConfig.InsecureSkipVerify = h.insecureskipverify
chrroberts-pure marked this conversation as resolved.
Show resolved Hide resolved

scrapeConfig := &config.ScrapeConfig{
HTTPClientConfig: httpConfig,
ScrapeProtocols: config.DefaultScrapeProtocols,
ScrapeInterval: model.Duration(h.scrapeInterval),
ScrapeTimeout: model.Duration(h.scrapeInterval),
JobName: fmt.Sprintf("%s/%s/%s", "purefa", h.scraperType, arr.Address),
HonorTimestamps: true,
Scheme: u.Scheme,
MetricsPath: fmt.Sprintf("/metrics/%s", h.scraperType),
Params: url.Values{
"endpoint": {arr.Address},
"endpoint": {arr.Address},
"namespace": {h.namespace},
},

ServiceDiscoveryConfigs: discovery.Configs{
Expand Down
7 changes: 6 additions & 1 deletion receiver/purefareceiver/internal/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func TestToPrometheusConfig(t *testing.T) {
}

endpoint := "http://example.com"
namespace := "purefa"
insecureskipverify := true
interval := 15 * time.Second
cfgs := []ScraperConfig{
{
Expand All @@ -47,15 +49,18 @@ func TestToPrometheusConfig(t *testing.T) {
},
}

scraper := NewScraper(context.Background(), "hosts", endpoint, cfgs, interval, model.LabelSet{})
scraper := NewScraper(context.Background(), "hosts", endpoint, namespace, insecureskipverify, cfgs, interval, model.LabelSet{})

// test
scCfgs, err := scraper.ToPrometheusReceiverConfig(host, prFactory)

// verify
assert.NoError(t, err)
assert.Len(t, scCfgs, 1)
assert.NotNil(t, scCfgs[0].ScrapeProtocols)
assert.EqualValues(t, "purefa", scCfgs[0].Params.Get("namespace"))
assert.EqualValues(t, "the-token", scCfgs[0].HTTPClientConfig.BearerToken)
assert.True(t, scCfgs[0].HTTPClientConfig.TLSConfig.InsecureSkipVerify)
assert.Equal(t, "array01", scCfgs[0].Params.Get("endpoint"))
assert.Equal(t, "/metrics/hosts", scCfgs[0].MetricsPath)
assert.Equal(t, "purefa/hosts/array01", scCfgs[0].JobName)
Expand Down
10 changes: 5 additions & 5 deletions receiver/purefareceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,35 @@ func (r *purefaReceiver) Start(ctx context.Context, compHost component.Host) err
"fa_array_name": ArrayName,
}

arrScraper := internal.NewScraper(ctx, internal.ScraperTypeArray, r.cfg.Endpoint, r.cfg.Array, r.cfg.Settings.ReloadIntervals.Array, commomLabel)
arrScraper := internal.NewScraper(ctx, internal.ScraperTypeArray, r.cfg.Endpoint, r.cfg.Namespace, r.cfg.TLSSetting.InsecureSkipVerify, r.cfg.Array, r.cfg.Settings.ReloadIntervals.Array, commomLabel)
if scCfgs, err := arrScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

hostScraper := internal.NewScraper(ctx, internal.ScraperTypeHosts, r.cfg.Endpoint, r.cfg.Hosts, r.cfg.Settings.ReloadIntervals.Hosts, labelSet)
hostScraper := internal.NewScraper(ctx, internal.ScraperTypeHosts, r.cfg.Endpoint, r.cfg.Namespace, r.cfg.TLSSetting.InsecureSkipVerify, r.cfg.Hosts, r.cfg.Settings.ReloadIntervals.Hosts, labelSet)
if scCfgs, err := hostScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

directoriesScraper := internal.NewScraper(ctx, internal.ScraperTypeDirectories, r.cfg.Endpoint, r.cfg.Directories, r.cfg.Settings.ReloadIntervals.Directories, commomLabel)
directoriesScraper := internal.NewScraper(ctx, internal.ScraperTypeDirectories, r.cfg.Endpoint, r.cfg.Namespace, r.cfg.TLSSetting.InsecureSkipVerify, r.cfg.Directories, r.cfg.Settings.ReloadIntervals.Directories, commomLabel)
if scCfgs, err := directoriesScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

podsScraper := internal.NewScraper(ctx, internal.ScraperTypePods, r.cfg.Endpoint, r.cfg.Pods, r.cfg.Settings.ReloadIntervals.Pods, commomLabel)
podsScraper := internal.NewScraper(ctx, internal.ScraperTypePods, r.cfg.Endpoint, r.cfg.Namespace, r.cfg.TLSSetting.InsecureSkipVerify, r.cfg.Pods, r.cfg.Settings.ReloadIntervals.Pods, commomLabel)
if scCfgs, err := podsScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

volumesScraper := internal.NewScraper(ctx, internal.ScraperTypeVolumes, r.cfg.Endpoint, r.cfg.Volumes, r.cfg.Settings.ReloadIntervals.Volumes, labelSet)
volumesScraper := internal.NewScraper(ctx, internal.ScraperTypeVolumes, r.cfg.Endpoint, r.cfg.Namespace, r.cfg.TLSSetting.InsecureSkipVerify, r.cfg.Volumes, r.cfg.Settings.ReloadIntervals.Volumes, labelSet)
if scCfgs, err := volumesScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
Expand Down
1 change: 1 addition & 0 deletions receiver/purefareceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ receivers:

purefa/with_custom_intervals:
fa_array_name: foobar.example.com
namespace: purefa
endpoint: http://172.31.60.208:9490/metrics
array:
- address: array01
Expand Down
Loading