-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wire up remaining integrations v2 for the static to flow converter (#…
…5935) * wire up app_agent_receiver for integrations v2 static to flow converter Signed-off-by: erikbaranowski <[email protected]> * mark eventhandler integration unsupported for now Signed-off-by: erikbaranowski <[email protected]> * wire up vsphere exporter for static to integrations v2 converter Signed-off-by: erikbaranowski <[email protected]> --------- Signed-off-by: erikbaranowski <[email protected]>
- Loading branch information
1 parent
f2e3984
commit 3c7f8c0
Showing
9 changed files
with
256 additions
and
1 deletion.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
converter/internal/staticconvert/internal/build/app_agent_receiver.go
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,84 @@ | ||
package build | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alecthomas/units" | ||
"github.com/grafana/agent/component/common/loki" | ||
"github.com/grafana/agent/component/faro/receiver" | ||
"github.com/grafana/agent/component/otelcol" | ||
"github.com/grafana/agent/converter/diag" | ||
"github.com/grafana/agent/converter/internal/common" | ||
app_agent_receiver_v2 "github.com/grafana/agent/pkg/integrations/v2/app_agent_receiver" | ||
"github.com/grafana/river/rivertypes" | ||
"github.com/grafana/river/scanner" | ||
) | ||
|
||
func (b *IntegrationsConfigBuilder) appendAppAgentReceiverV2(config *app_agent_receiver_v2.Config) { | ||
args := toAppAgentReceiverV2(config) | ||
|
||
compLabel, err := scanner.SanitizeIdentifier(b.formatJobName(config.Name(), nil)) | ||
if err != nil { | ||
b.diags.Add(diag.SeverityLevelCritical, fmt.Sprintf("failed to sanitize job name: %s", err)) | ||
} | ||
|
||
b.f.Body().AppendBlock(common.NewBlockWithOverride( | ||
[]string{"faro", "receiver"}, | ||
compLabel, | ||
args, | ||
)) | ||
} | ||
|
||
func toAppAgentReceiverV2(config *app_agent_receiver_v2.Config) *receiver.Arguments { | ||
var logLabels map[string]string | ||
if config.LogsLabels != nil { | ||
logLabels = config.LogsLabels | ||
} | ||
|
||
logsReceiver := common.ConvertLogsReceiver{} | ||
if config.LogsInstance != "" { | ||
compLabel, err := scanner.SanitizeIdentifier("logs_" + config.LogsInstance) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to sanitize job name: %s", err)) | ||
} | ||
|
||
logsReceiver.Expr = fmt.Sprintf("loki.write.%s.receiver", compLabel) | ||
} | ||
|
||
return &receiver.Arguments{ | ||
LogLabels: logLabels, | ||
Server: receiver.ServerArguments{ | ||
Host: config.Server.Host, | ||
Port: config.Server.Port, | ||
CORSAllowedOrigins: config.Server.CORSAllowedOrigins, | ||
APIKey: rivertypes.Secret(config.Server.APIKey), | ||
MaxAllowedPayloadSize: units.Base2Bytes(config.Server.MaxAllowedPayloadSize), | ||
RateLimiting: receiver.RateLimitingArguments{ | ||
Enabled: config.Server.RateLimiting.Enabled, | ||
Rate: config.Server.RateLimiting.RPS, | ||
BurstSize: float64(config.Server.RateLimiting.Burstiness), | ||
}, | ||
}, | ||
SourceMaps: receiver.SourceMapsArguments{ | ||
Download: config.SourceMaps.Download, | ||
DownloadFromOrigins: config.SourceMaps.DownloadFromOrigins, | ||
DownloadTimeout: config.SourceMaps.DownloadTimeout, | ||
Locations: toLocationArguments(config.SourceMaps.FileSystem), | ||
}, | ||
Output: receiver.OutputArguments{ | ||
Logs: []loki.LogsReceiver{logsReceiver}, | ||
Traces: []otelcol.Consumer{}, | ||
}, | ||
} | ||
} | ||
|
||
func toLocationArguments(locations []app_agent_receiver_v2.SourceMapFileLocation) []receiver.LocationArguments { | ||
args := make([]receiver.LocationArguments, len(locations)) | ||
for i, location := range locations { | ||
args[i] = receiver.LocationArguments{ | ||
Path: location.Path, | ||
MinifiedPathPrefix: location.MinifiedPathPrefix, | ||
} | ||
} | ||
return args | ||
} |
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
25 changes: 25 additions & 0 deletions
25
converter/internal/staticconvert/internal/build/vmware_exporter.go
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,25 @@ | ||
package build | ||
|
||
import ( | ||
"github.com/grafana/agent/component/discovery" | ||
"github.com/grafana/agent/component/prometheus/exporter/vsphere" | ||
vmware_exporter_v2 "github.com/grafana/agent/pkg/integrations/v2/vmware_exporter" | ||
"github.com/grafana/river/rivertypes" | ||
) | ||
|
||
func (b *IntegrationsConfigBuilder) appendVmwareExporterV2(config *vmware_exporter_v2.Config) discovery.Exports { | ||
args := toVmwareExporter(config) | ||
return b.appendExporterBlock(args, config.Name(), nil, "vsphere") | ||
} | ||
|
||
func toVmwareExporter(config *vmware_exporter_v2.Config) *vsphere.Arguments { | ||
return &vsphere.Arguments{ | ||
ChunkSize: config.ChunkSize, | ||
CollectConcurrency: config.CollectConcurrency, | ||
VSphereURL: config.VSphereURL, | ||
VSphereUser: config.VSphereUser, | ||
VSpherePass: rivertypes.Secret(config.VSpherePass), | ||
ObjectDiscoveryInterval: config.ObjectDiscoveryInterval, | ||
EnableExporterMetrics: config.EnableExporterMetrics, | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
converter/internal/staticconvert/testdata-v2/unsupported.diags
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,3 @@ | ||
(Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. | ||
(Error) The converter does not support converting the provided eventhandler integration. | ||
(Error) The converter does not support converting the provided app_agent_receiver traces_instance config. |
36 changes: 36 additions & 0 deletions
36
converter/internal/staticconvert/testdata-v2/unsupported.river
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,36 @@ | ||
prometheus.remote_write "metrics_default" { | ||
endpoint { | ||
name = "default-8be96f" | ||
url = "http://localhost:9009/api/prom/push" | ||
|
||
queue_config { } | ||
|
||
metadata_config { } | ||
} | ||
} | ||
|
||
faro.receiver "integrations_app_agent_receiver" { | ||
extra_log_labels = {} | ||
|
||
server { | ||
listen_address = "localhost" | ||
listen_port = 55678 | ||
max_allowed_payload_size = "4MiB786KiB832B" | ||
|
||
rate_limiting { | ||
enabled = true | ||
rate = 100 | ||
burst_size = 50 | ||
} | ||
} | ||
|
||
sourcemaps { | ||
download_from_origins = ["*"] | ||
download_timeout = "1s" | ||
} | ||
|
||
output { | ||
logs = [] | ||
traces = [] | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
converter/internal/staticconvert/testdata-v2/unsupported.yaml
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 @@ | ||
|
||
metrics: | ||
global: | ||
remote_write: | ||
- url: http://localhost:9009/api/prom/push | ||
configs: | ||
- name: default | ||
|
||
integrations: | ||
app_agent_receiver_configs: | ||
- instance: "default" | ||
traces_instance: "not_supported" | ||
server: | ||
host: "localhost" | ||
port: 55678 | ||
eventhandler: | ||
cache_path: "/etc/eventhandler/eventhandler.cache" |
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