-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add promtail converters support for GCPLog (#4607)
- Loading branch information
Showing
14 changed files
with
344 additions
and
97 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
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,41 @@ | ||
package gcptypes | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
fnet "github.com/grafana/agent/component/common/net" | ||
) | ||
|
||
// PullConfig configures a GCPLog target with the 'pull' strategy. | ||
type PullConfig struct { | ||
ProjectID string `river:"project_id,attr"` | ||
Subscription string `river:"subscription,attr"` | ||
Labels map[string]string `river:"labels,attr,optional"` | ||
UseIncomingTimestamp bool `river:"use_incoming_timestamp,attr,optional"` | ||
UseFullLine bool `river:"use_full_line,attr,optional"` | ||
} | ||
|
||
// PushConfig configures a GCPLog target with the 'push' strategy. | ||
type PushConfig struct { | ||
Server *fnet.ServerConfig `river:",squash"` | ||
PushTimeout time.Duration `river:"push_timeout,attr,optional"` | ||
Labels map[string]string `river:"labels,attr,optional"` | ||
UseIncomingTimestamp bool `river:"use_incoming_timestamp,attr,optional"` | ||
UseFullLine bool `river:"use_full_line,attr,optional"` | ||
} | ||
|
||
// SetToDefault implements river.Defaulter. | ||
func (p *PushConfig) SetToDefault() { | ||
*p = PushConfig{ | ||
Server: fnet.DefaultServerConfig(), | ||
} | ||
} | ||
|
||
// Validate implements river.Validator. | ||
func (p *PushConfig) Validate() error { | ||
if p.PushTimeout < 0 { | ||
return fmt.Errorf("push_timeout must be greater than zero") | ||
} | ||
return nil | ||
} |
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
40 changes: 0 additions & 40 deletions
40
component/loki/source/gcplog/internal/gcplogtarget/types.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 |
---|---|---|
@@ -1,47 +1,7 @@ | ||
package gcplogtarget | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
fnet "github.com/grafana/agent/component/common/net" | ||
) | ||
|
||
// Target is a common interface implemented by both GCPLog targets. | ||
type Target interface { | ||
Details() map[string]string | ||
Stop() error | ||
} | ||
|
||
// PullConfig configures a GCPLog target with the 'pull' strategy. | ||
type PullConfig struct { | ||
ProjectID string `river:"project_id,attr"` | ||
Subscription string `river:"subscription,attr"` | ||
Labels map[string]string `river:"labels,attr,optional"` | ||
UseIncomingTimestamp bool `river:"use_incoming_timestamp,attr,optional"` | ||
UseFullLine bool `river:"use_full_line,attr,optional"` | ||
} | ||
|
||
// PushConfig configures a GCPLog target with the 'push' strategy. | ||
type PushConfig struct { | ||
Server *fnet.ServerConfig `river:",squash"` | ||
PushTimeout time.Duration `river:"push_timeout,attr,optional"` | ||
Labels map[string]string `river:"labels,attr,optional"` | ||
UseIncomingTimestamp bool `river:"use_incoming_timestamp,attr,optional"` | ||
UseFullLine bool `river:"use_full_line,attr,optional"` | ||
} | ||
|
||
// SetToDefault implements river.Defaulter. | ||
func (p *PushConfig) SetToDefault() { | ||
*p = PushConfig{ | ||
Server: fnet.DefaultServerConfig(), | ||
} | ||
} | ||
|
||
// Validate implements river.Validator. | ||
func (p *PushConfig) Validate() error { | ||
if p.PushTimeout < 0 { | ||
return fmt.Errorf("push_timeout must be greater than zero") | ||
} | ||
return nil | ||
} |
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.