Skip to content

Commit 63811d0

Browse files
authored
[exporter/azureblobexporter] New component for azureblobexporter skeleton - First PR (open-telemetry#37788)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description First PR for new component, azureblobexporter. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue open-telemetry#34319 <!--Describe what testing was performed and which tests were added.--> #### Testing No tests at this point. <!--Describe the documentation added.--> #### Documentation As `README.md` showed. This is the first PR for new exporter component, Azure Blob exporter. After this PR merged, I'll add another implementation PR. <!--Please delete paragraphs that you did not use before submitting.-->
1 parent 994853d commit 63811d0

24 files changed

+989
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: new_component
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: azureblobexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add new exporter for sending telemetry to Azure Storage Blob
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35717]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ exporter/awsemfexporter/ @open-telemetry
4646
exporter/awskinesisexporter/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @MovieStoreGuy
4747
exporter/awss3exporter/ @open-telemetry/collector-contrib-approvers @atoulme @pdelewski
4848
exporter/awsxrayexporter/ @open-telemetry/collector-contrib-approvers @wangzlei @srprash
49+
exporter/azureblobexporter/ @open-telemetry/collector-contrib-approvers @hgaol
4950
exporter/azuredataexplorerexporter/ @open-telemetry/collector-contrib-approvers @ag-ramachandran
5051
exporter/azuremonitorexporter/ @open-telemetry/collector-contrib-approvers @pcwiese @hgaol
5152
exporter/bmchelixexporter/ @open-telemetry/collector-contrib-approvers @bertysentry @NassimBtk @MovieStoreGuy

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ body:
4646
- exporter/awskinesis
4747
- exporter/awss3
4848
- exporter/awsxray
49+
- exporter/azureblob
4950
- exporter/azuredataexplorer
5051
- exporter/azuremonitor
5152
- exporter/bmchelix

.github/ISSUE_TEMPLATE/feature_request.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ body:
4040
- exporter/awskinesis
4141
- exporter/awss3
4242
- exporter/awsxray
43+
- exporter/azureblob
4344
- exporter/azuredataexplorer
4445
- exporter/azuremonitor
4546
- exporter/bmchelix

.github/ISSUE_TEMPLATE/other.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ body:
4040
- exporter/awskinesis
4141
- exporter/awss3
4242
- exporter/awsxray
43+
- exporter/azureblob
4344
- exporter/azuredataexplorer
4445
- exporter/azuremonitor
4546
- exporter/bmchelix

.github/ISSUE_TEMPLATE/unmaintained.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ body:
4545
- exporter/awskinesis
4646
- exporter/awss3
4747
- exporter/awsxray
48+
- exporter/azureblob
4849
- exporter/azuredataexplorer
4950
- exporter/azuremonitor
5051
- exporter/bmchelix

cmd/otelcontribcol/builder-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ exporters:
6464
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awss3exporter v0.120.0
6565
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsxrayexporter v0.120.0
6666
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuredataexplorerexporter v0.120.0
67+
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azureblobexporter v0.120.0
6768
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter v0.120.0
6869
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/bmchelixexporter v0.120.0
6970
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter v0.120.0

exporter/azureblobexporter/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../Makefile.Common

exporter/azureblobexporter/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Azure Blob Exporter for OpenTelemetry Collector
2+
3+
<!-- status autogenerated section -->
4+
| Status | |
5+
| ------------- |-----------|
6+
| Stability | [development]: traces, metrics, logs |
7+
| Distributions | [] |
8+
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Fazureblob%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fazureblob) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Fazureblob%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fazureblob) |
9+
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@hgaol](https://www.github.com/hgaol) |
10+
11+
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development
12+
<!-- end autogenerated section -->
13+
14+
## Configuration
15+
16+
The following settings are required:
17+
18+
- url: Must be specified if auth type is not connection_string. If auth type is connection_string, it's optional or will be override by the auth.connection_string. Azure storage account endpoint. This setting might be replaced with `endpoint` for future. e.g. https://<account-name>.blob.core.windows.net/
19+
- auth (no default): Authentication method for exporter to ingest data.
20+
- type (no default): Authentication type for expoter. supported values are: connection_string, service_principal, system_managed_identity, user_managed_identity and etc.
21+
- tenand_id: Tenand Id for the client, only needed when type is service_principal.
22+
- client_id: Client Id for the auth, only needed when type is service_principal and user_managed_identity.
23+
- client_secret: Secret for the client, only needed when type is service_principal.
24+
- connection_string: Connection string to the endpoint. Only needed for connection_string auth type. Once provided, it'll **override** the `url` parameter to the storage account.
25+
26+
27+
The following settings can be optionally configured and have default values:
28+
29+
- container: container for metrics, logs and traces. A container organizes a set of blobs, similar to a directory in a file system. More details can refer [this](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction#containers).
30+
- metrics (default `metrics`): container to store metrics. default value is `metrics`.
31+
- logs (default `logs`): container to store logs. default value is `logs`.
32+
- traces (default `traces`): container to store traces. default value is `traces`.
33+
- blob_name_format:
34+
- metrics_format (default `2006/01/02/metrics_15_04_05_{{.SerialNum}}.{{.FileExtension}}`): blob name format. The date format follows constants in Golang, refer [here](https://go.dev/src/time/format.go).
35+
- logs_format (default `2006/01/02/logs_15_04_05_{{.SerialNum}}.{{.FileExtension}}`): blob name format.
36+
- traces_format (default `2006/01/02/traces_15_04_05_{{.SerialNum}}.{{.FileExtension}}`): blob name format.
37+
- serial_num_range (default `10000`): a range of random number for SerialNum.
38+
- format (default `json`): `json` or `proto`. which present otel json or otel protobuf format, the file extension will be `json` or `pb`.
39+
- encoding (default none): if specified, uses an encoding extension to encode telemetry data. Overrides format.
40+
41+
An example configuration is provided as follows:
42+
43+
```yaml
44+
azureblobexporter:
45+
url: "https://<your-account>.blob.core.windows.net/"
46+
container:
47+
logs: "logs"
48+
metrics: "metrics"
49+
traces: "traces"
50+
auth:
51+
type: "connection_string"
52+
connection_string: "DefaultEndpointsProtocol=https;AccountName=<your-acount>;AccountKey=<account-key>;EndpointSuffix=core.windows.net"
53+
```

exporter/azureblobexporter/config.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package azureblobexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azureblobexporter"
5+
6+
import (
7+
"errors"
8+
9+
"go.opentelemetry.io/collector/component"
10+
)
11+
12+
type TelemetryConfig struct {
13+
Logs string `mapstructure:"logs"`
14+
Metrics string `mapstructure:"metrics"`
15+
Traces string `mapstructure:"traces"`
16+
}
17+
18+
type (
19+
Container TelemetryConfig
20+
BlobName TelemetryConfig
21+
)
22+
23+
type BlobNameFormat struct {
24+
MetricsFormat string `mapstructure:"metrics_format"`
25+
LogsFormat string `mapstructure:"logs_format"`
26+
TracesFormat string `mapstructure:"traces_format"`
27+
SerialNumRange int64 `mapstructure:"serial_num_range"`
28+
Params map[string]string `mapstructure:"params"`
29+
}
30+
31+
type Authentication struct {
32+
// Type is the authentication type. supported values are connection_string, service_principal, system_managed_identity and user_managed_identity
33+
Type AuthType `mapstructure:"type"`
34+
35+
// TenantID is the tenand id for the AAD App. It's only needed when type is service principal.
36+
TenantID string `mapstructure:"tenant_id"`
37+
38+
// ClientID is the AAD Application client id. It's needed when type is service principal or user managed identity
39+
ClientID string `mapstructure:"client_id"`
40+
// ClientSecret only needed when auth type is service_principal
41+
42+
ClientSecret string `mapstructure:"client_secret"`
43+
44+
// ConnectionString to the endpoint.
45+
ConnectionString string `mapstructure:"connection_string"`
46+
}
47+
48+
type AuthType string
49+
50+
const (
51+
ConnectionString AuthType = "connection_string"
52+
SystemManagedIdentity AuthType = "system_managed_identity"
53+
UserManagedIdentity AuthType = "user_managed_identity"
54+
ServicePrincipal AuthType = "service_principal"
55+
)
56+
57+
// Config contains the main configuration options for the azure storage blob exporter
58+
type Config struct {
59+
URL string `mapstructure:"url"`
60+
Container *Container `mapstructure:"container"`
61+
Auth *Authentication `mapstructure:"auth"`
62+
BlobNameFormat *BlobNameFormat `mapstructure:"blob_name_format"`
63+
FormatType string `mapstructure:"format"`
64+
// Encoding to apply. If present, overrides the marshaler configuration option.
65+
Encoding *component.ID `mapstructure:"encoding"`
66+
}
67+
68+
func (c *Config) Validate() error {
69+
if c.URL == "" && c.Auth.Type != ConnectionString {
70+
return errors.New("url cannot be empty when auth type is not connection_string")
71+
}
72+
73+
switch c.Auth.Type {
74+
case ConnectionString:
75+
if c.Auth.ConnectionString == "" {
76+
return errors.New("connection_string cannot be empty when auth type is connection_string")
77+
}
78+
case ServicePrincipal:
79+
if c.Auth.TenantID == "" || c.Auth.ClientID == "" || c.Auth.ClientSecret == "" {
80+
return errors.New("tenant_id, client_id and client_secret cannot be empty when auth type is service-principal")
81+
}
82+
case UserManagedIdentity:
83+
if c.Auth.ClientID == "" {
84+
return errors.New("client_id cannot be empty when auth type is user_managed_identity")
85+
}
86+
}
87+
88+
if c.FormatType != formatTypeJSON && c.FormatType != formatTypeProto {
89+
return errors.New("unknown format type: " + c.FormatType)
90+
}
91+
92+
return nil
93+
}

0 commit comments

Comments
 (0)