Skip to content

Commit

Permalink
[receiver/purefb] New Pure Storage FlashBlade receiver (open-telemetr…
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoscn committed Jan 25, 2023
1 parent 2fc0da0 commit e53dd69
Show file tree
Hide file tree
Showing 29 changed files with 2,134 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .chloggen/add_new_purefb_receiver.yaml
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:
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ receiver/promtailreceiver/ @open-telemetry/collect
receiver/rabbitmqreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @cpheps
receiver/pulsarreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @tjiuming
receiver/purefareceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
receiver/purefbreceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
receiver/receivercreator/ @open-telemetry/collector-contrib-approvers @rmfitzpatrick
receiver/redisreceiver/ @open-telemetry/collector-contrib-approvers @pmcollins @dmitryax
receiver/riakreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @armstrmi
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ body:
- receiver/promtail
- receiver/pulsar
- receiver/purefa
- receiver/purefb
- receiver/rabbitmq
- receiver/receivercreator
- receiver/redis
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ body:
- receiver/promtail
- receiver/pulsar
- receiver/purefa
- receiver/purefb
- receiver/rabbitmq
- receiver/receivercreator
- receiver/redis
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ body:
- receiver/promtail
- receiver/pulsar
- receiver/purefa
- receiver/purefb
- receiver/rabbitmq
- receiver/receivercreator
- receiver/redis
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ updates:
directory: "/receiver/purefareceiver"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/receiver/purefbreceiver"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/receiver/rabbitmqreceiver"
schedule:
Expand Down
3 changes: 3 additions & 0 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/riakreceiver v0.70.0 // indirect
Expand Down Expand Up @@ -962,6 +963,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsa

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver => ../../receiver/purefareceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver => ../../receiver/purefbreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver => ../../receiver/rabbitmqreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator => ../../receiver/receivercreator
Expand Down
3 changes: 3 additions & 0 deletions cmd/otelcontribcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator v0.70.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver v0.70.0 // indirect
Expand Down Expand Up @@ -722,6 +723,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/e

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver => ../../receiver/purefareceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver => ../../receiver/purefbreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/probabilisticsamplerprocessor => ../../processor/probabilisticsamplerprocessor

replace github.com/open-telemetry/opentelemetry-collector-contrib/extension/observer/hostobserver => ../../extension/observer/hostobserver
Expand Down
2 changes: 2 additions & 0 deletions cmd/oteltestbedcol/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/exporter/tanzu

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver => ../../receiver/purefareceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver => ../../receiver/purefbreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver => ../../receiver/postgresqlreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourceprocessor => ../../processor/resourceprocessor
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator v0.70.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver v0.70.0
Expand Down Expand Up @@ -965,6 +966,8 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsa

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver => ./receiver/purefareceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver => ./receiver/purefbreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver => ./receiver/rabbitmqreceiver

replace github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator => ./receiver/receivercreator
Expand Down
2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/pulsarreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefbreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/receivercreator"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver"
Expand Down Expand Up @@ -270,6 +271,7 @@ func Components() (otelcol.Factories, error) {
// promtailreceiver.NewFactory(),
pulsarreceiver.NewFactory(),
purefareceiver.NewFactory(),
purefbreceiver.NewFactory(),
rabbitmqreceiver.NewFactory(),
receivercreator.NewFactory(),
redisreceiver.NewFactory(),
Expand Down
3 changes: 3 additions & 0 deletions internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ func TestDefaultReceivers(t *testing.T) {
{
receiver: "purefa",
},
{
receiver: "purefb",
},
{
receiver: "receiver_creator",
},
Expand Down
1 change: 1 addition & 0 deletions receiver/purefbreceiver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../Makefile.Common
53 changes: 53 additions & 0 deletions receiver/purefbreceiver/README.md
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
74 changes: 74 additions & 0 deletions receiver/purefbreceiver/config.go
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
}
69 changes: 69 additions & 0 deletions receiver/purefbreceiver/config_test.go
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)
})
}
}
Loading

0 comments on commit e53dd69

Please sign in to comment.