forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/purefb] New Pure Storage FlashBlade receiver (open-telemetr…
- Loading branch information
Showing
29 changed files
with
2,134 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: new_component | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: receiver/purefbreceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add a new receiver that scrapes metrics using Purestorage FlashBlade API | ||
|
||
# One or more tracking issues related to the change | ||
issues: [17528] | ||
|
||
# (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: |
Validating CODEOWNERS rules …
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
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 @@ | ||
include ../../Makefile.Common |
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,53 @@ | ||
# Pure Storage FlashBlade Receiver | ||
|
||
| Status | | | ||
| ------------------------ |---------------------| | ||
| Stability | [in-development] | | ||
| Supported pipeline types | metrics | | ||
| Distributions | [contrib] | | ||
|
||
The Pure Storage FlashBlade receiver, receives metrics from Pure Storage FlashBlade via the [Pure Storage FlashBlade OpenMetrics Exporter](https://github.com/PureStorage-OpenConnect/pure-fb-openmetrics-exporter) | ||
|
||
Supported pipeline types: metrics | ||
|
||
## Configuration | ||
|
||
The following settings are required: | ||
- `endpoint` (default: `http:https://172.31.60.207:9491/metrics/array`): The URL of the scraper selected endpoint | ||
|
||
### Important | ||
|
||
- Only endpoints explicitly added on will be scraped. e.g: `clients` | ||
|
||
Example: | ||
|
||
```yaml | ||
extensions: | ||
bearertokenauth/fb01: | ||
token: "..." | ||
|
||
receivers: | ||
purefb: | ||
endpoint: http:https://172.31.60.207:9491/metrics | ||
arrays: | ||
- address: fb01 | ||
auth: | ||
authenticator: bearertokenauth/fb01 | ||
clients: | ||
- address: fb01 | ||
auth: | ||
authenticator: bearertokenauth/fb01 | ||
env: dev | ||
settings: | ||
reload_intervals: | ||
array: 5m | ||
clients: 6m | ||
usage: 6m | ||
|
||
``` | ||
|
||
The full list of settings exposed for this receiver are documented [here](./config.go) | ||
with detailed sample configurations [here](./testdata/config.yaml). | ||
|
||
[in-development]: https://github.com/open-telemetry/opentelemetry-collector#in-development | ||
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib |
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,74 @@ | ||
// Copyright 2023 The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http:https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package purefbreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver" | ||
|
||
import ( | ||
"errors" | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/confighttp" | ||
"go.uber.org/multierr" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver/internal" | ||
) | ||
|
||
var _ component.Config = (*Config)(nil) | ||
|
||
// Config relating to Array Metric Scraper. | ||
type Config struct { | ||
confighttp.HTTPClientSettings `mapstructure:",squash"` | ||
|
||
// Settings contains settings for the individual scrapers | ||
Settings *Settings `mapstructure:"settings"` | ||
|
||
// Arrays represents the list of arrays to query | ||
Arrays []internal.ScraperConfig `mapstructure:"arrays"` | ||
|
||
// Clients represents the list of clients metrics | ||
Clients []internal.ScraperConfig `mapstructure:"clients"` | ||
|
||
// Usage represents the list of usage to query | ||
Usage []internal.ScraperConfig `mapstructure:"usage"` | ||
|
||
// Env represents the respective environment value valid to scrape | ||
Env string `mapstructure:"env"` | ||
} | ||
|
||
type Settings struct { | ||
ReloadIntervals *ReloadIntervals `mapstructure:"reload_intervals"` | ||
} | ||
|
||
type ReloadIntervals struct { | ||
Array time.Duration `mapstructure:"array"` | ||
Clients time.Duration `mapstructure:"clients"` | ||
Usage time.Duration `mapstructure:"usage"` | ||
} | ||
|
||
func (c *Config) Validate() error { | ||
var err error | ||
|
||
if c.Settings.ReloadIntervals.Array == 0 { | ||
err = multierr.Append(err, errors.New("reload interval for 'arrays' must be provided")) | ||
} | ||
if c.Settings.ReloadIntervals.Clients == 0 { | ||
err = multierr.Append(err, errors.New("reload interval for 'clients' must be provided")) | ||
} | ||
if c.Settings.ReloadIntervals.Usage == 0 { | ||
err = multierr.Append(err, errors.New("reload interval for 'usage' must be provided")) | ||
} | ||
|
||
return err | ||
} |
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,69 @@ | ||
// Copyright 2023 The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http:https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package purefbreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver" | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/confmap/confmaptest" | ||
) | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) | ||
require.NoError(t, err) | ||
|
||
tests := []struct { | ||
id component.ID | ||
expected component.Config | ||
}{ | ||
{ | ||
id: component.NewID(typeStr), | ||
expected: &Config{ | ||
Settings: &Settings{ | ||
ReloadIntervals: &ReloadIntervals{ | ||
Array: 15 * time.Second, | ||
Clients: 5 * time.Minute, | ||
Usage: 5 * time.Minute, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.id.String(), func(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
|
||
sub, err := cm.Sub(tt.id.String()) | ||
require.NoError(t, err) | ||
require.NoError(t, component.UnmarshalConfig(sub, cfg)) | ||
|
||
assert.NoError(t, component.ValidateConfig(cfg)) | ||
assert.Equal(t, tt.expected, cfg) | ||
|
||
expected := factory.CreateDefaultConfig().(*Config) | ||
|
||
require.Equal(t, expected, cfg) | ||
}) | ||
} | ||
} |
Oops, something went wrong.