Documentation
¶
Index ¶
- Variables
- func LoadConfig(ctx context.Context, profile string) (aws.Config, error)
- func SortEntries[E Entry, D EntryData[E]](data D)
- type API
- type Client
- type DesiredState
- type Entry
- type EntryData
- type Filter
- type FilterKey
- type FilterOperator
- type ListEntry
- type ListEntryData
- type Manager
- func (man *Manager) Apply(w io.Writer) (int32, error)
- func (man *Manager) List() (*ListEntryData, error)
- func (man *Manager) Preview() (*PreviewEntryData, error)
- func (man *Manager) SetDesiredState(desired DesiredState) error
- func (man *Manager) SetFilter(filters []Filter) error
- func (man *Manager) SetRegion(regions []string) error
- func (man *Manager) String() string
- type OutputType
- type PreviewEntry
- type PreviewEntryData
- type Renderer
- type Retryer
- func (r *Retryer) GetAttemptToken(context.Context) (func(error) error, error)
- func (r *Retryer) GetInitialToken() func(error) error
- func (r *Retryer) GetRetryToken(context.Context, error) (func(error) error, error)
- func (r *Retryer) IsErrorRetryable(err error) bool
- func (r *Retryer) MaxAttempts() int
- func (r *Retryer) RetryDelay(int, error) (time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
var ( // PageTitle is the title of the HTML page. PageTitle = "llcm" // BaseName is the base name of the HTML file. BaseName = "llcm" // MaxPieChartItems is the maximum number of items in a pie chart. MaxPieChartItems = 11 // MaxBarChartItems is the maximum number of items in a bar chart. MaxBarChartItems = 31 // PieChartTitle is the title of the pie chart. PieChartTitle = "Stored bytes of log groups" // barChartTitle is the title of the bar chart. BarChartTitle = "The simulation of reductions in log groups" )
var ( // DefaultRegion is the region speficied by default. DefaultRegion = "us-east-1" // DefaultRegions is the default target regions. DefaultRegions = []string{ "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "sa-east-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2", } )
var ( // TotalStoredBytesLabel is the label of the total stored bytes. TotalStoredBytesLabel = "storedBytes" // TotalReducibleBytesLabel is the label of the total reducible bytes. TotalReducibleBytesLabel = "reducibleBytes" // TotalRemainingBytesLabel is the label of the total remaining bytes. TotalRemainingBytesLabel = "remainingBytes" )
var ( // MaxRetryAttempts is the maximum number of retry attempts. MaxRetryAttempts = 10 // DelayTimeSec is the sleep time in seconds for retry. DelayTimeSec = 3 )
var NumWorker = int64(runtime.NumCPU()*2 + 1)
NumWorker is the number of workers for concurrent processing.
Functions ¶
func LoadConfig ¶
LoadConfig loads the aws config.
func SortEntries ¶
SortEntries sorts the entries by bytes and name.
Types ¶
type API ¶
type API interface { DescribeLogGroups(ctx context.Context, params *cloudwatchlogs.DescribeLogGroupsInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.DescribeLogGroupsOutput, error) PutRetentionPolicy(ctx context.Context, params *cloudwatchlogs.PutRetentionPolicyInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.PutRetentionPolicyOutput, error) DeleteRetentionPolicy(ctx context.Context, params *cloudwatchlogs.DeleteRetentionPolicyInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.DeleteRetentionPolicyOutput, error) DeleteLogGroup(ctx context.Context, params *cloudwatchlogs.DeleteLogGroupInput, optFns ...func(*cloudwatchlogs.Options)) (*cloudwatchlogs.DeleteLogGroupOutput, error) }
API represents an interface for CloudWatch Logs.
type DesiredState ¶
type DesiredState int32
DesiredState represents the desired state of the log group.
const ( DesiredStateNone DesiredState = -9999 // A value meaning none. DesiredStateZero DesiredState = 0 // A value meaning delete the log group. DesiredStateOneDay DesiredState = 1 // A value meaning retain the log group for one day. DesiredStateThreeDays DesiredState = 3 // A value meaning retain the log group for three days. DesiredStateFiveDays DesiredState = 5 // A value meaning retain the log group for five days. DesiredStateOneWeek DesiredState = 7 // A value meaning retain the log group for one week. DesiredStateTwoWeeks DesiredState = 14 // A value meaning retain the log group for two weeks. DesiredStateOneMonth DesiredState = 30 // A value meaning retain the log group for one month. DesiredStateTwoMonths DesiredState = 60 // A value meaning retain the log group for two months. DesiredStateThreeMonths DesiredState = 90 // A value meaning retain the log group for three months. DesiredStateFourMonths DesiredState = 120 // A value meaning retain the log group for four months. DesiredStateFiveMonths DesiredState = 150 // A value meaning retain the log group for five months. DesiredStateSixMonths DesiredState = 180 // A value meaning retain the log group for six months. DesiredStateOneYear DesiredState = 365 // A value meaning retain the log group for one year. DesiredStateThirteenMonths DesiredState = 400 // A value meaning retain the log group for thirteen months. DesiredStateEighteenMonths DesiredState = 545 // A value meaning retain the log group for eighteen months. DesiredStateTwoYears DesiredState = 731 // A value meaning retain the log group for two years. DesiredStateThreeYears DesiredState = 1096 // A value meaning retain the log group for three years. DesiredStateFiveYears DesiredState = 1827 // A value meaning retain the log group for five years. DesiredStateSixYears DesiredState = 2192 // A value meaning retain the log group for six years. DesiredStateSevenYears DesiredState = 255 // A value meaning retain the log group for seven years. DesiredStateEightYears DesiredState = 2922 // A value meaning retain the log group for eight years. DesiredStateNineYears DesiredState = 3288 // A value meaning retain the log group for nine years. DesiredStateTenYears DesiredState = 3653 // A value meaning retain the log group for ten years. DesiredStateInfinite DesiredState = 9999 // A value meaning retain the log group infinity. )
func ParseDesiredState ¶
func ParseDesiredState(s string) (DesiredState, error)
ParseDesiredState parses a string into a DesiredState.
func (DesiredState) MarshalJSON ¶
func (t DesiredState) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the DesiredState.
func (DesiredState) String ¶
func (t DesiredState) String() string
String returns the string representation of the DesiredState.
type Entry ¶
type Entry interface { Name() string // Name returns the name of the entry. Bytes() int64 // Bytes returns the stored bytes of the entry. DataSet() map[string]int64 // DataSet returns map for plotting the chart. // contains filtered or unexported methods }
Entry is an interface for log group entry.
type EntryData ¶
type EntryData[T Entry] interface { Header() []string Entries() []T Total() map[string]int64 Chart() error }
EntryData represents the collection of entries.
type Filter ¶
type Filter struct { Key FilterKey // The key of the filter expression Operator FilterOperator // The operator of the filter expression Value string // The value of the filter expression }
Filter represents a filter expression for filtering log group entries.
func EvaluateFilter ¶
EvaluateFilter evaluates the filter expressions.
type FilterKey ¶
type FilterKey int
FilterKey represents the key to filter by.
const ( FilterKeyNone FilterKey = iota // The key meaning none. FilterKeyName // The key meaning "name" corresponding LogGroupName. FilterKeyClass // The key meaning "class" corresponding Class. FilterKeyElapsed // The key meaning "elapsed" corresponding ElapsedDays. FilterKeyRetention // The key meaning "retention" corresponding RetentionInDays. FilterKeyBytes // The key meaning "bytes" corresponding StoredBytes. )
func (FilterKey) MarshalJSON ¶
MarshalJSON returns the JSON representation of the FilterKey.
type FilterOperator ¶
type FilterOperator int
FilterOperator represents the operator to filter by.
const ( FilterOperatorNone FilterOperator = iota // The operator meaning none. FilterOperatorGT // The operator meaning "greater than". FilterOperatorGTE // The operator meaning "greater than or equal to". FilterOperatorLT // The operator meaning "less than". FilterOperatorLTE // The operator meaning "less than or equal to". FilterOperatorEQ // The operator meaning "equal". FilterOperatorEQI // The operator meaning "equal" (case-insensitive). FilterOperatorNEQ // The operator meaning "not equal". FilterOperatorNEQI // The operator meaning "not equal" (case-insensitive). FilterOperatorREQ // The operator meaning regular expression match. FilterOperatorREQI // The operator meaning regular expression match (case-insensitive). FilterOperatorNREQ // The operator meaning regular expression unmatch. FilterOperatorNREQI // The operator meaning regular expression unmatch (case-insensitive). )
func (FilterOperator) MarshalJSON ¶
func (t FilterOperator) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the FilterOperator.
func (FilterOperator) String ¶
func (t FilterOperator) String() string
String returns the string representation of the FilterOperator.
type ListEntry ¶
type ListEntry struct {
// contains filtered or unexported fields
}
ListEntry represents an entry to list log group.
func (ListEntry) Bytes ¶
func (e ListEntry) Bytes() int64
Bytes returns the stored bytes of the entry.
type ListEntryData ¶
type ListEntryData struct { TotalStoredBytes int64 // The total stored bytes of the log groups. // contains filtered or unexported fields }
ListEntryData represents the collection of ListEntry.
func (*ListEntryData) Chart ¶ added in v0.0.14
func (d *ListEntryData) Chart() error
Chart generates a pie chart for the ListEntryData.
func (*ListEntryData) Entries ¶
func (d *ListEntryData) Entries() []*ListEntry
Entries returns the entries of the ListEntryData.
func (*ListEntryData) Header ¶
func (d *ListEntryData) Header() []string
Header returns the header of the ListEntryData.
func (*ListEntryData) Total ¶
func (d *ListEntryData) Total() map[string]int64
Total returns the total of the ListEntryData.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager represents a log group lifecycle manager.
func NewManager ¶
NewManager creates a new manager for log group lifecycle management.
func (*Manager) List ¶
func (man *Manager) List() (*ListEntryData, error)
List lists the log group entries.
func (*Manager) Preview ¶
func (man *Manager) Preview() (*PreviewEntryData, error)
Preview returns the log group entries with the desired state and its simulated results.
func (*Manager) SetDesiredState ¶
func (man *Manager) SetDesiredState(desired DesiredState) error
SetDesiredState sets the desired state.
type OutputType ¶
type OutputType int
OutputType represents the type of output to render.
const ( OutputTypeNone OutputType = iota // The output type that means none. OutputTypeJSON // The output type of JSON format. OutputTypePrettyJSON // The output type of pretty JSON format. OutputTypeText // The output type of text table format. OutputTypeCompressedText // The output type of compressed text table format. OutputTypeMarkdown // The output type of markdown table format. OutputTypeBacklog // The output type of backlog table format. OutputTypeTSV // The output type of tab-separated values. OutputTypeChart // The output type that means pie chart. )
func ParseOutputType ¶
func ParseOutputType(s string) (OutputType, error)
ParseOutputType parses a string into an OutputType.
func (OutputType) MarshalJSON ¶
func (t OutputType) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the OutputType.
func (OutputType) String ¶
func (t OutputType) String() string
String returns the string representation of the OutputType.
type PreviewEntry ¶
type PreviewEntry struct { BytesPerDay int64 // The bytes per day of the log group. DesiredState int64 // The desired state of the log group. ReductionInDays int64 // The number of days to be reduced after the action. ReducibleBytes int64 // The number of bytes that can be reduced after the action. RemainingBytes int64 // The number of bytes that remain after the action. // contains filtered or unexported fields }
PreviewEntry is an extended representation of entry with the desired state and its simulated results.
func (PreviewEntry) Bytes ¶
func (e PreviewEntry) Bytes() int64
Bytes returns the stored bytes of the entry.
func (*PreviewEntry) DataSet ¶ added in v0.0.13
func (e *PreviewEntry) DataSet() map[string]int64
DataSet returns map for plotting the chart.
type PreviewEntryData ¶
type PreviewEntryData struct { TotalStoredBytes int64 // The total stored bytes of the log groups. TotalReducibleBytes int64 // The total reducible bytes of the log groups. TotalRemainingBytes int64 // The total remaining bytes of the log groups. // contains filtered or unexported fields }
PreviewEntryData represents the collection of PreviewEntry.
func (*PreviewEntryData) Chart ¶ added in v0.0.14
func (d *PreviewEntryData) Chart() error
Chart generates a bar chart for the PreviewEntryData.
func (*PreviewEntryData) Entries ¶
func (d *PreviewEntryData) Entries() []*PreviewEntry
Entries returns the entries of the PreviewEntryData.
func (*PreviewEntryData) Header ¶
func (d *PreviewEntryData) Header() []string
Header returns the header of the PreviewEntryData.
func (*PreviewEntryData) Total ¶
func (d *PreviewEntryData) Total() map[string]int64
Total returns the total of the PreviewEntryData.
type Renderer ¶
type Renderer[E Entry, D EntryData[E]] struct { Data D OutputType OutputType // contains filtered or unexported fields }
OutputType represents the type of the output.
func NewRenderer ¶
func NewRenderer[E Entry, D EntryData[E]](w io.Writer, data D, outputType OutputType) *Renderer[E, D]
NewRenderer creates a new renderer with the specified parameters.
type Retryer ¶
type Retryer struct {
// contains filtered or unexported fields
}
Retryer represents a retryer for avoiding api rate limit exceeded.
func NewRetryer ¶
NewRetryer creates a new retryer.
func (*Retryer) GetAttemptToken ¶
GetAttemptToken returns the attempt token.
func (*Retryer) GetInitialToken ¶
GetInitialToken returns the initial token.
func (*Retryer) GetRetryToken ¶
GetRetryToken returns the retry token.
func (*Retryer) IsErrorRetryable ¶
IsErrorRetryable checks if the error is retryable.
func (*Retryer) MaxAttempts ¶
MaxAttempts returns the maximum number of retry attempts.