costdb

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2017 Applatix, Inc.

Copyright 2017 Applatix, Inc.

Copyright 2017 Applatix, Inc.

Index

Constants

View Source
const (
	EventIngestStart    = "STARTED"
	EventIngestFinished = "FINISHED"
	EventIngestError    = "ERROR"
)

Ingest events

Variables

This section is empty.

Functions

This section is empty.

Types

type CostDatabase

type CostDatabase struct {
	ServerURL string
	// contains filtered or unexported fields
}

CostDatabase provides an interface to store and query cost and usage information from a cost database

func NewCostDatabase

func NewCostDatabase(dbURL string) (costDb *CostDatabase, err error)

NewCostDatabase returns a CostDatabase instance

func (*CostDatabase) Close

func (db *CostDatabase) Close()

Close underlying client

func (*CostDatabase) CreateDatabase

func (db *CostDatabase) CreateDatabase() error

CreateDatabase create the database

func (*CostDatabase) DropDatabase

func (db *CostDatabase) DropDatabase() error

DropDatabase will drop entire database

func (*CostDatabase) GetIngestStatus

func (db *CostDatabase) GetIngestStatus(assemblyID string) (*IngestStatus, error)

GetIngestStatus returns the ingest status of an Manifest assembly

func (*CostDatabase) GetIngestStatusByBillingPeriod

func (db *CostDatabase) GetIngestStatusByBillingPeriod(bucket, reportPath, billingPeriod string) (*IngestStatus, error)

GetIngestStatusByBillingPeriod returns the ingest status of a bucket and billing period

func (*CostDatabase) GetReportIDs

func (db *CostDatabase) GetReportIDs() ([]string, error)

GetReportIDs returns all report IDs known by the cost database

func (*CostDatabase) NewCostReportContext

func (db *CostDatabase) NewCostReportContext(reportID string) *CostReportContext

NewCostReportContext returns a context in which to perform cost queries

func (*CostDatabase) Query

func (db *CostDatabase) Query(cmd string, args ...interface{}) ([]client.Result, error)

Query performs a InfluxDB query

func (*CostDatabase) Wait

func (db *CostDatabase) Wait()

Wait will wait until database is ready

func (*CostDatabase) Write

func (db *CostDatabase) Write(bp client.BatchPoints) error

Write takes a BatchPoints object and writes all Points to InfluxDB while retrying the operation several times

type CostQuery

type CostQuery struct {
	Aggregator string
	Field      string
	From       time.Time
	To         time.Time
	GroupBy    string
	Interval   Interval
	Blended    bool
	Filters    map[string][]string
}

CostQuery is the object representation of a cost database query for cost or usages * Aggregator is a format string, e.g: "COUNT(DISTINCT\"%s\"))" * Field is the column to query against, e.g. "lineItem/UnblendedCost"" * From/To is the timeframe in which to perform the query * GroupBy is the column name in which to group the query by * Filters will is a mapping of column names to values in which to filter by

type CostReportContext

type CostReportContext struct {
	CostDB   *CostDatabase
	ReportID string
	// contains filtered or unexported fields
}

CostReportContext provides a querying interface in the context of a user report

func (*CostReportContext) Cost

func (ctx *CostReportContext) Cost(params *CostQuery) ([]models.Row, error)

Cost perform a cost query

func (*CostReportContext) CountRecords

func (ctx *CostReportContext) CountRecords() (int64, error)

CountRecords counts the total number of records in the measurement

func (*CostReportContext) CreateRetentionPolicy

func (ctx *CostReportContext) CreateRetentionPolicy(days int) error

CreateRetentionPolicy creates the retention policy for this report

func (*CostReportContext) DeleteAllIngestHistory

func (ctx *CostReportContext) DeleteAllIngestHistory() error

DeleteAllIngestHistory deletes all ingest history for this report

func (*CostReportContext) DeleteAssemblyIngestHistory

func (ctx *CostReportContext) DeleteAssemblyIngestHistory(assemblyID string) error

DeleteAssemblyIngestHistory deletes ingest history for a given assembly id Called when updating a retention policy results in the need for reprocessing of report data

func (*CostReportContext) DeleteBillingBucketHistory

func (ctx *CostReportContext) DeleteBillingBucketHistory(bucketname, reportPath string) error

DeleteBillingBucketHistory deletes all ingest history for the billing bucket & report path Called when a report bucket has been deleted

func (*CostReportContext) DeleteReportBillingBucketData

func (ctx *CostReportContext) DeleteReportBillingBucketData(bucketname, reportPath string) error

DeleteReportBillingBucketData deletes all report data for a specific billing bucket/report path

func (*CostReportContext) DeleteReportData

func (ctx *CostReportContext) DeleteReportData() error

DeleteReportData deletes all report data for the measurement

func (*CostReportContext) DropRetentionPolicy

func (ctx *CostReportContext) DropRetentionPolicy() error

DropRetentionPolicy deletes the retention policy for this report

func (*CostReportContext) GetDimension

func (ctx *CostReportContext) GetDimension(dimension string, filters map[string][]string) (*Dimension, error)

GetDimension gets the possible values of a dimension

func (*CostReportContext) GetReportBuckets

func (ctx *CostReportContext) GetReportBuckets() ([]*billingbucket.AWSBillingBucket, error)

GetReportBuckets all buckets associated with the report

func (*CostReportContext) GetReportIngestStatuses

func (ctx *CostReportContext) GetReportIngestStatuses() ([]*IngestStatus, error)

GetReportIngestStatuses returns the ingest status of the report (e.g. if there are any errors)

func (*CostReportContext) GetResourceTagDimension

func (ctx *CostReportContext) GetResourceTagDimension(filters map[string][]string) (*Dimension, error)

GetResourceTagDimension returns all resource tags and their possible values

func (*CostReportContext) GetRetentionPolicy

func (ctx *CostReportContext) GetRetentionPolicy() (int, error)

GetRetentionPolicy gets the retention policy for this report in days

func (*CostReportContext) GetServiceDimension

func (ctx *CostReportContext) GetServiceDimension(filters map[string][]string) (*Dimension, error)

GetServiceDimension returns a slice of services with their dimensions

func (*CostReportContext) GetUsageUnits

func (ctx *CostReportContext) GetUsageUnits(serviceName string) ([]*UsageUnit, error)

GetUsageUnits returns all usage units of a particular service, and the usage families it applies to

func (*CostReportContext) NewBatchPoints

func (ctx *CostReportContext) NewBatchPoints() (client.BatchPoints, error)

NewBatchPoints returns a new batch points with the database and retention policy set. NOTE: precision is left as nanoseconds despite billing reports only having hourly report granularity, because we use a nanosecond sequence number added to each timestamp to ensure we do not lose any points from InfluxDB's point duplication logic. Per recomendation, we can increase the timestamp by a nanosecond to prevent point duplication. See: https://docs.influxdata.com/influxdb/v1.1/troubleshooting/frequently-asked-questions/#how-does-influxdb-handle-duplicate-points

func (*CostReportContext) NewPoint

func (ctx *CostReportContext) NewPoint(tags map[string]string, fields map[string]interface{}, t ...time.Time) (*client.Point, error)

NewPoint returns a InfluxDB point ready to be stored in this costDB's measurement

func (*CostReportContext) PurgeBillingPeriodSeries

func (ctx *CostReportContext) PurgeBillingPeriodSeries(bucketname, reportPath, billingPeriod string) error

PurgeBillingPeriodSeries will drop data points corresponding to the given billing period This is desired for when current month's data needs to be replaced (new report is generated)

func (*CostReportContext) RecordIngestError

func (ctx *CostReportContext) RecordIngestError(manifest billingbucket.Manifest, errorMsg string) error

RecordIngestError will record in the database an error processing a report

func (*CostReportContext) RecordIngestFinish

func (ctx *CostReportContext) RecordIngestFinish(manifest billingbucket.Manifest) error

RecordIngestFinish will record in the database the completion of a processing in the report

func (*CostReportContext) RecordIngestStart

func (ctx *CostReportContext) RecordIngestStart(manifest billingbucket.Manifest) error

RecordIngestStart will record in the database the start of a processing in the report

func (*CostReportContext) SeriesCardinality

func (ctx *CostReportContext) SeriesCardinality() (int, error)

SeriesCardinality Return cardinality of the measurement

func (*CostReportContext) TagValues

func (ctx *CostReportContext) TagValues(column parser.Column, filters map[string][]string) ([]string, error)

TagValues return tag values of a particular column. Filters are mapping from column name to value

func (*CostReportContext) UpdateRetentionPolicy

func (ctx *CostReportContext) UpdateRetentionPolicy(days int) (bool, error)

UpdateRetentionPolicy updates the retention policy for this report. If retention is increased, it purges ingest_status history during the the increased duration time period

type Dimension

type Dimension struct {
	DisplayName string       `json:"display_name"`
	Name        string       `json:"name"`
	UsageUnits  []*UsageUnit `json:"usage_units,omitempty"`
	Dimensions  []*Dimension `json:"dimensions,omitempty"`
}

Dimension represents a way of grouping or filtering a cost query. Dimensions are nested in a tree structure

type IngestStatus

type IngestStatus struct {
	ReportID      string     `json:"report_id"`
	AssemblyID    string     `json:"assembly_id"`
	Bucket        string     `json:"bucket"`
	ReportPath    string     `json:"report_path"`
	BillingPeriod string     `json:"billing_period"`
	ErrorMessage  string     `json:"error,omitempty"`
	ParserVersion int        `json:"parser_version"`
	StartTime     *time.Time `json:"start_time"`
	FinishTime    *time.Time `json:"finish_time"`
}

IngestStatus is the ingest status of a Manifest assembly

func (*IngestStatus) StatusDetail

func (is *IngestStatus) StatusDetail() (claudia.ReportStatus, string)

StatusDetail returns status and detail which can be used as a report status

type Interval

type Interval string

Interval is a time interval used for grouping cost queries

const (
	Hour  Interval = "1h"
	Day   Interval = "1d"
	Week  Interval = "1w"
	Month Interval = "1M"
)

Interval when aggregating data

func ParseInterval

func ParseInterval(intervalString string) (Interval, error)

ParseInterval parses a string as an interval

type UsageUnit

type UsageUnit struct {
	Name          string   `json:"name"`
	UsageFamilies []string `json:"usagefamilies,omitempty"`
}

UsageUnit is a datastructure representing a usage pricing unit (e.g. GB, GB-Mo, Requests, Hr), and the usage family it applies to

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL