Skip to content

Commit

Permalink
Merge pull request #59 from similarweb/feature/add-kinesis-resource-d…
Browse files Browse the repository at this point in the history
…etection

Feature/add kinesis resource detection
  • Loading branch information
cregev authored Jun 14, 2020
2 parents 3789d3e + 5a8c212 commit a5d3b2d
Show file tree
Hide file tree
Showing 19 changed files with 506 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.3.0]
- Add the option to notify by tags a notification group [[PR-56](https://github.com/similarweb/finala/pull/56)]
- Fix Dynamodb price calculation [[PR-57](https://github.com/similarweb/finala/pull/57)]
- Add Kinesis unused resource detection [[PR-59](https://github.com/similarweb/finala/pull/59)]

## [0.2.1]
- Add Neptune unused database detection [[PR-52](https://github.com/similarweb/finala/pull/52)]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AWS:
* IAM user last activity
* Lambda
* Neptune

* Kinesis
More to come...

## Screenshots
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/docdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (dd *DocumentDBManager) Detect() ([]DetectedDocumentDB, error) {

log.WithField("name", *instance.DBInstanceIdentifier).Debug("checking documentDB")

price, _ := dd.#Client.GetPrice(dd.Get#FilterInput(instance), "")
price, _ := dd.#Client.GetPrice(dd.Get#FilterInput(instance), "", dd.region)

for _, metric := range dd.metrics {
log.WithFields(log.Fields{
Expand Down Expand Up @@ -167,7 +167,7 @@ func (dd *DocumentDBManager) Detect() ([]DetectedDocumentDB, error) {
ResourceID: *instance.DBInstanceArn,
LaunchTime: *instance.InstanceCreateTime,
PricePerHour: price,
PricePerMonth: price * 720,
PricePerMonth: price * collector.TotalMonthHours,
TotalSpendPrice: totalPrice,
Tag: tagsData,
},
Expand Down
8 changes: 4 additions & 4 deletions collector/aws/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (dd *DynamoDBManager) Detect() ([]DetectedAWSDynamoDB, error) {
return detectedTables, err
}

writePricePerHour, _ := dd.#Client.GetPrice(dd.Get#WriteFilterInput(), rateCode)
readPricePerHour, _ := dd.#Client.GetPrice(dd.Get#ReadFilterInput(), rateCode)
writePricePerHour, _ := dd.#Client.GetPrice(dd.Get#WriteFilterInput(), rateCode, dd.region)
readPricePerHour, _ := dd.#Client.GetPrice(dd.Get#ReadFilterInput(), rateCode, dd.region)

for _, table := range tables {

Expand Down Expand Up @@ -168,13 +168,13 @@ func (dd *DynamoDBManager) Detect() ([]DetectedAWSDynamoDB, error) {
provisionedWriteCapacityUnits := metricsResponseValues["ProvisionedWriteCapacityUnits"].(float64)
pricePerHour = writePricePerHour
totalPrice = pricePerHour * provisionedWriteCapacityUnits * durationRunningTime.Hours()
pricePerMonth = provisionedWriteCapacityUnits * pricePerHour * 720
pricePerMonth = provisionedWriteCapacityUnits * pricePerHour * collector.TotalMonthHours

} else if strings.Contains(metric.Description, "read capacity") {
provisionedReadCapacityUnits := metricsResponseValues["ProvisionedReadCapacityUnits"].(float64)
pricePerHour = readPricePerHour
totalPrice = pricePerHour * provisionedReadCapacityUnits * durationRunningTime.Hours()
pricePerMonth = provisionedReadCapacityUnits * pricePerHour * 720
pricePerMonth = provisionedReadCapacityUnits * pricePerHour * collector.TotalMonthHours
} else {
log.Warn("metric name not supported")
continue
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (ec *EC2Manager) Detect() ([]DetectedEC2, error) {
for _, instance := range instances {
log.WithField("instance_id", *instance.InstanceId).Debug("checking ec2 instance")

price, _ := ec.#Client.GetPrice(ec.Get#FilterInput(instance), "")
price, _ := ec.#Client.GetPrice(ec.Get#FilterInput(instance), "", ec.region)

for _, metric := range ec.metrics {
log.WithFields(log.Fields{
Expand Down Expand Up @@ -168,7 +168,7 @@ func (ec *EC2Manager) Detect() ([]DetectedEC2, error) {
ResourceID: *instance.InstanceId,
LaunchTime: *instance.LaunchTime,
PricePerHour: price,
PricePerMonth: price * 720,
PricePerMonth: price * collector.TotalMonthHours,
TotalSpendPrice: totalPrice,
Tag: tagsData,
},
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/ec2volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (ev *EC2VolumeManager) Detect() ([]DetectedAWSEC2Volume, error) {

log.WithField("id", *vol.VolumeId).Debug("cheking ec2 volume")

price, err := ev.#Client.GetPrice(ev.GetBase#FilterInput(vol, filters), "")
price, err := ev.#Client.GetPrice(ev.GetBase#FilterInput(vol, filters), "", ev.region)
if err != nil {
log.WithError(err).WithFields(log.Fields{
"volume_id": *vol.VolumeId,
Expand Down Expand Up @@ -155,7 +155,7 @@ func (ev *EC2VolumeManager) GetCalculatedPrice(vol *ec2.Volume, basePrice float6
},
}

iopsPrice, err := ev.#Client.GetPrice(ev.GetBase#FilterInput(vol, extraFilter), "")
iopsPrice, err := ev.#Client.GetPrice(ev.GetBase#FilterInput(vol, extraFilter), "", ev.region)
if err != nil {
iopsPrice = 0
}
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/elasticache.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (ec *ElasticacheManager) Detect() ([]DetectedElasticache, error) {
for _, instance := range instances {
log.WithField("cluster_id", *instance.CacheClusterId).Debug("checking elasticache")

price, _ := ec.#Client.GetPrice(ec.Get#FilterInput(instance), "")
price, _ := ec.#Client.GetPrice(ec.Get#FilterInput(instance), "", ec.region)

for _, metric := range ec.metrics {
log.WithFields(log.Fields{
Expand Down Expand Up @@ -169,7 +169,7 @@ func (ec *ElasticacheManager) Detect() ([]DetectedElasticache, error) {
LaunchTime: *instance.CacheClusterCreateTime,
ResourceID: *instance.CacheClusterId,
PricePerHour: price,
PricePerMonth: price * 720,
PricePerMonth: price * collector.TotalMonthHours,
TotalSpendPrice: totalPrice,
Tag: tagsData,
},
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (el *ELBManager) Detect() ([]DetectedELB, error) {
for _, instance := range instances {
log.WithField("name", *instance.LoadBalancerName).Debug("checking elb")

price, _ := el.#Client.GetPrice(el.Get#FilterInput(), "")
price, _ := el.#Client.GetPrice(el.Get#FilterInput(), "", el.region)

for _, metric := range el.metrics {

Expand Down Expand Up @@ -167,7 +167,7 @@ func (el *ELBManager) Detect() ([]DetectedELB, error) {
ResourceID: *instance.LoadBalancerName,
LaunchTime: *instance.CreatedTime,
PricePerHour: price,
PricePerMonth: price * 720,
PricePerMonth: price * collector.TotalMonthHours,
TotalSpendPrice: totalPrice,
Tag: tagsData,
},
Expand Down
4 changes: 2 additions & 2 deletions collector/aws/elbv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (el *ELBV2Manager) Detect() ([]DetectedELBV2, error) {

log.WithField("name", *instance.LoadBalancerName).Debug("cheking elbV2")

price, _ := el.#Client.GetPrice(el.Get#FilterInput(), "")
price, _ := el.#Client.GetPrice(el.Get#FilterInput(), "", el.region)

for _, metric := range el.metrics {

Expand Down Expand Up @@ -173,7 +173,7 @@ func (el *ELBV2Manager) Detect() ([]DetectedELBV2, error) {
ResourceID: *instance.LoadBalancerName,
LaunchTime: *instance.CreatedTime,
PricePerHour: price,
PricePerMonth: price * 720,
PricePerMonth: price * collector.TotalMonthHours,
TotalSpendPrice: totalPrice,
Tag: tagsData,
},
Expand Down
Loading

0 comments on commit a5d3b2d

Please # to comment.