Documentation ¶
Index ¶
- func GetLogEntryMessage(entry *loggingpb.LogEntry) (string, error)
- func GetLogLabels(entry *loggingpb.LogEntry) data.Labels
- func GetLogLevel(severity ltype.LogSeverity) string
- type API
- type Client
- func (c *Client) Close() error
- func (c *Client) ListLogs(ctx context.Context, q *Query) ([]*loggingpb.LogEntry, error)
- func (c *Client) ListProjectBucketViews(ctx context.Context, projectId string, bucketId string) ([]string, error)
- func (c *Client) ListProjectBuckets(ctx context.Context, projectId string) ([]string, error)
- func (c *Client) ListProjects(ctx context.Context) ([]string, error)
- func (c *Client) TestConnection(ctx context.Context, projectID string) error
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLogEntryMessage ¶
GetLogEntryMessage gets the message body of a LogEntry based on what kind of payload it is If it's JSON, we look for the `message` field since the other fields will be added as labels
func GetLogLabels ¶
GetLogLabels flattens a log entry's labels + resource labels into a map
func GetLogLevel ¶
func GetLogLevel(severity ltype.LogSeverity) string
GetLogLevel maps the string value of a LogSeverity to one supported by Grafana
Types ¶
type API ¶
type API interface { // ListLogs retrieves all logs matching some query filter up to the given limit ListLogs(context.Context, *Query) ([]*loggingpb.LogEntry, error) // TestConnection queries for any log from the given project TestConnection(ctx context.Context, projectID string) error // ListProjects returns the project IDs of all visible projects ListProjects(context.Context) ([]string, error) // ListProjectBuckets returns all log buckets of a project ListProjectBuckets(ctx context.Context, projectId string) ([]string, error) // ListProjectBucketViews returns all views of a log bucket ListProjectBucketViews(ctx context.Context, projectId string, bucketId string) ([]string, error) // Close closes the underlying connection to the GCP API Close() error }
API implements the methods we need to query logs and list projects from GCP
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a GCP logging client to fetch logs, a resourcemanager client to list projects, and a config client to get log bucket configurations
func NewClientWithGCE ¶ added in v1.2.0
NewClient creates a new Clients using GCE metadata for authentication
func NewClientWithImpersonation ¶ added in v1.4.0
func NewClientWithImpersonation(ctx context.Context, jsonCreds []byte, impersonateSA string) (*Client, error)
NewClient creates a new Clients using service account impersonation
func (*Client) ListLogs ¶
ListLogs retrieves all logs matching some query filter up to the given limit
func (*Client) ListProjectBucketViews ¶ added in v1.2.1
func (c *Client) ListProjectBucketViews(ctx context.Context, projectId string, bucketId string) ([]string, error)
ListProjectBucketsViews returns all views of a log bucket
func (*Client) ListProjectBuckets ¶ added in v1.2.1
ListProjectBuckets returns all log buckets of a project
func (*Client) ListProjects ¶
ListProjects returns the project IDs of all visible projects