-
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.
Converter static improvements (#5175)
* include comments about diags that come from other converters * correctly check and handle unsupported integrations that don't scrape * better grpc error message * go mod tidy * rename common.go to river_utils.go * add support for logging to static converter * wire up itegrations http_tls_config * wire up server for static converter Signed-off-by: erikbaranowski <[email protected]> * Update converter/internal/staticconvert/validate.go Co-authored-by: Robert Fratto <[email protected]> --------- Signed-off-by: erikbaranowski <[email protected]> Co-authored-by: Robert Fratto <[email protected]>
- Loading branch information
1 parent
c8d6fcf
commit 2126955
Showing
22 changed files
with
423 additions
and
66 deletions.
There are no files selected for viewing
File renamed without changes.
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
27 changes: 27 additions & 0 deletions
27
converter/internal/staticconvert/internal/build/logging.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,27 @@ | ||
package build | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/grafana/agent/converter/internal/common" | ||
"github.com/grafana/agent/pkg/flow/logging" | ||
"github.com/grafana/agent/pkg/server" | ||
) | ||
|
||
func (b *IntegrationsV1ConfigBuilder) appendLogging(config *server.Config) { | ||
args := toLogging(config) | ||
if !reflect.DeepEqual(*args, logging.DefaultOptions) { | ||
b.f.Body().AppendBlock(common.NewBlockWithOverride( | ||
[]string{"logging"}, | ||
"", | ||
args, | ||
)) | ||
} | ||
} | ||
|
||
func toLogging(config *server.Config) *logging.Options { | ||
return &logging.Options{ | ||
Level: logging.Level(config.LogLevel.String()), | ||
Format: logging.Format(config.LogFormat.String()), | ||
} | ||
} |
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,61 @@ | ||
package build | ||
|
||
import ( | ||
"reflect" | ||
|
||
"github.com/grafana/agent/converter/internal/common" | ||
"github.com/grafana/agent/pkg/server" | ||
"github.com/grafana/agent/service/http" | ||
) | ||
|
||
func (b *IntegrationsV1ConfigBuilder) appendServer(config *server.Config) { | ||
args := toServer(config) | ||
if !reflect.DeepEqual(*args.TLS, http.TLSArguments{}) { | ||
b.f.Body().AppendBlock(common.NewBlockWithOverride( | ||
[]string{"http"}, | ||
"", | ||
args, | ||
)) | ||
} | ||
} | ||
|
||
func toServer(config *server.Config) *http.Arguments { | ||
authType, err := server.GetClientAuthFromString(config.HTTP.TLSConfig.ClientAuth) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return &http.Arguments{ | ||
TLS: &http.TLSArguments{ | ||
Cert: "", | ||
CertFile: config.HTTP.TLSConfig.TLSCertPath, | ||
Key: "", | ||
KeyFile: config.HTTP.TLSConfig.TLSKeyPath, | ||
ClientCA: "", | ||
ClientCAFile: config.HTTP.TLSConfig.ClientCAs, | ||
ClientAuth: http.ClientAuth(authType), | ||
CipherSuites: toHTTPTLSCipher(config.HTTP.TLSConfig.CipherSuites), | ||
CurvePreferences: toHTTPTLSCurve(config.HTTP.TLSConfig.CurvePreferences), | ||
MinVersion: http.TLSVersion(config.HTTP.TLSConfig.MinVersion), | ||
MaxVersion: http.TLSVersion(config.HTTP.TLSConfig.MaxVersion), | ||
}, | ||
} | ||
} | ||
|
||
func toHTTPTLSCipher(cipherSuites []server.TLSCipher) []http.TLSCipher { | ||
var result []http.TLSCipher | ||
for _, cipcipherSuite := range cipherSuites { | ||
result = append(result, http.TLSCipher(cipcipherSuite)) | ||
} | ||
|
||
return result | ||
} | ||
|
||
func toHTTPTLSCurve(curvePreferences []server.TLSCurve) []http.TLSCurve { | ||
var result []http.TLSCurve | ||
for _, curvePreference := range curvePreferences { | ||
result = append(result, http.TLSCurve(curvePreference)) | ||
} | ||
|
||
return result | ||
} |
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
18 changes: 18 additions & 0 deletions
18
converter/internal/staticconvert/testdata-race/example-cert.pem
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,18 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIC6jCCAdICCQCOLEZvJLYQlDANBgkqhkiG9w0BAQsFADA3MQswCQYDVQQGEwJV | ||
UzELMAkGA1UECAwCRkwxDDAKBgNVBAoMA09yZzENMAsGA1UEAwwEcm9vdDAeFw0y | ||
MjAzMDkxNjM1NTRaFw0zMjAzMDYxNjM1NTRaMDcxCzAJBgNVBAYTAlVTMQswCQYD | ||
VQQIDAJGTDEMMAoGA1UECgwDT3JnMQ0wCwYDVQQDDARyb290MIIBIjANBgkqhkiG | ||
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx63pDVP4z4psrU6i5qOCUSjUGFkGRUekdrJ9 | ||
FtkOEyoQSl2hpkF+QAGvM2L3+bqH8Y1CZ7yakkCncSmzpXShVg2D2nxHkwYVGhmz | ||
rzwHttmewokrWtw72ta6v9gxljxNLjz+HsYovKFGbudnOcK3BxseluikrOM08fEi | ||
SF7Y1FJkyr103K7yjtRyNH2tKHGiK73wjkLBkd6WWFIrtMbNP0McXqkipOSg9dwY | ||
OKfuVDzD/fCkW24j2pgHAI+4TQWC6PSIGMVZ76I5hhYd0WLi/8KaBu/gfqmDjnBn | ||
qqJONoAxT5kEmXWwE5jO0ZOWx88S2D9wmBNIx8HtMLh+7pVQ7QIDAQABMA0GCSqG | ||
SIb3DQEBCwUAA4IBAQBM85fNb+7b+3q0+uDw/fgrUkYfAVjJX+uN3ONy50qnKWe7 | ||
SAqLC76HVHLa9hdT7OENQurCCrEtnV1Fzg0KNqtE8gW5rPrV44FZrC5YnpqrHoKp | ||
VZeff+Mficioif5KkaELZILgduwYXe/H9r6qg87mHU4zpFlDUnUFCfLDtrO4fc79 | ||
BEpoUXLf5tCwRLUv/d0eeksMqUf5ES4tWfzUVLCjSEEcuX0GIgWdcyG3thCauPWC | ||
9a/QEXqqDC46AgsvkHCNWRoC8TSob5usTJDflodHoree6eaWx6j8ZGA/Uc0ohalJ | ||
XYGN7R9ge9KeqmwvYI6hr/n+WM92Jeqnz9BVWaiQ | ||
-----END CERTIFICATE----- |
27 changes: 27 additions & 0 deletions
27
converter/internal/staticconvert/testdata-race/example-key.pem
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,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpQIBAAKCAQEAx63pDVP4z4psrU6i5qOCUSjUGFkGRUekdrJ9FtkOEyoQSl2h | ||
pkF+QAGvM2L3+bqH8Y1CZ7yakkCncSmzpXShVg2D2nxHkwYVGhmzrzwHttmewokr | ||
Wtw72ta6v9gxljxNLjz+HsYovKFGbudnOcK3BxseluikrOM08fEiSF7Y1FJkyr10 | ||
3K7yjtRyNH2tKHGiK73wjkLBkd6WWFIrtMbNP0McXqkipOSg9dwY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YEAty6T8j+1I84PTA92c36jZ9llI+mRIdcsAjZR | ||
We0sRAmqk56LHiJjQvit4WmEizLSbWpL0ke6PckzNRVsf1ecBdqVN/6NEnTnln14 | ||
wkJv1GcSxVcPyr2YyYS1eWVnzufuVU0gDO6Z+1/vGwj/xJf3QgMTDY58pdztY5Ii | ||
jWI2fikCgYEAmGEmcPOu8IjYNN+YdQ1CeF909oSH++Nqr34IB5/e2Wr9WVknfHzZ | ||
wIfzlUJUQO0so0LDaB7UQKk0Xk3+OP6Udw8xFfr/P5s++bvnKr3j5iHn6taqPs+v | ||
PFxn+7KqdYVQ4RYRYLsy6NF+MhXt2sDAhiScxVnkh09t6sT1UG9xKW4= | ||
-----END RSA PRIVATE KEY----- |
10 changes: 5 additions & 5 deletions
10
.../staticconvert/testdata/unsupported.diags → ...icconvert/testdata-race/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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
(Error) global positions configuration is not supported - each Flow Mode's loki.source.file component has its own positions file in the component's data directory | ||
(Warning) server.log_level is not supported - Flow mode components may produce different logs | ||
(Error) unsupported integration which is not being scraped was provided: mssql. | ||
(Error) mapping_config is not supported in statsd_exporter integrations config | ||
(Warning) Please review your agent command line flags and ensure they are set in your Flow mode config file where necessary. | ||
(Error) unsupported log_level server config was provided. | ||
(Error) unsupported log_format server config was provided. | ||
(Error) unsupported grpc_tls_config server config was provided. | ||
(Error) unsupported http_tls_config server config was provided. | ||
(Error) unsupported grpc_tls_config server config was provided: flow mode does not have a gRPC server to configure. | ||
(Error) unsupported prefer_server_cipher_suites server config was provided. | ||
(Error) unsupported windows_certificate_filter server config was provided. | ||
(Error) unsupported wal_directory metrics config was provided. use the run command flag --storage.path for Flow mode instead. | ||
(Error) unsupported integration agent was provided. | ||
(Error) unsupported integration azure_exporter was provided. | ||
(Error) unsupported integration cadvisor was provided. | ||
(Error) unsupported disabled integration node_exporter. | ||
(Warning) disabled integrations do nothing and are not included in the output: node_exporter. | ||
(Error) unsupported traces config was provided. | ||
(Error) unsupported agent_management config was provided. |
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
Oops, something went wrong.