Skip to content

Commit

Permalink
POL-1204 Fix Outdated image-charts.com Links (#2161)
Browse files Browse the repository at this point in the history
* update

* fix

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update
  • Loading branch information
XOmniverse authored May 3, 2024
1 parent 93ed25e commit 44a5ecc
Show file tree
Hide file tree
Showing 23 changed files with 702 additions and 557 deletions.
12 changes: 8 additions & 4 deletions .dangerfile/policy_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,9 @@ def policy_bad_comma_spacing?(file)
return false
end

### Github Source File Test
# Return false if all datasources pointed to assets at raw.githubusercontent.com are valid
def policy_bad_github_datasources?(file)
### Outdated Links
# Return false if no outdated links are found
def policy_outdated_links?(file)
# Store contents of file for direct analysis
policy_code = File.read(file)

Expand All @@ -1192,6 +1192,10 @@ def policy_bad_github_datasources?(file)
policy_code.each_line.with_index do |line, index|
line_number = index + 1

if line.include?("https://image-charts.com")
fail_message += "Line #{line_number.to_s}: Direct link to `image-charts.com` found. Please replace `https://image-charts.com/chart?` with `https://api.image-charts-auth.flexeraeng.com/ic-function?rs_org_id={{ rs_org_id }}&rs_project_id={{ rs_project_id }}&`.\n\n"
end

if line.start_with?("datasource ")
within_datasource = true
datasource_line = line_number
Expand Down Expand Up @@ -1221,7 +1225,7 @@ def policy_bad_github_datasources?(file)
end
end

fail_message = "Invalid file paths found in datasources:\n\n" + fail_message if !fail_message.empty?
fail_message = "Invalid links found:\n\n" + fail_message if !fail_message.empty?

return fail_message.strip if !fail_message.empty?
return false
Expand Down
4 changes: 2 additions & 2 deletions .dangerfile/readme_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def readme_missing_sections?(file)
policy_actions_found = true if line.start_with?("## Policy Actions")
prerequisites_found = true if line.start_with?("## Prerequisites")
supported_clouds_found = true if line.start_with?("## Supported Clouds")
cost_found = true if line.start_with?("## Cost")
cost_found = true if line.strip == "## Cost"
end

fail_message += "```# Policy Name```\n" if !name_found
Expand Down Expand Up @@ -98,7 +98,7 @@ def readme_sections_out_of_order?(file)
policy_actions_found = true if line.start_with?("## Policy Actions")
prerequisites_found = true if line.start_with?("## Prerequisites")
supported_clouds_found = true if line.start_with?("## Supported Clouds")
cost_found = true if line.start_with?("## Cost")
cost_found = true if line.strip == "## Cost"

if !what_it_does_raised && what_it_does_found && !name_found
fail_message += "Line #{line_number.to_s}: What It Does out of order.\n"
Expand Down
4 changes: 2 additions & 2 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ changed_pt_files.each do |file|
# Raise warning if recommendation policy is missing recommended export fields
test = policy_missing_recommendation_fields?(file, "recommended"); warnings << test if test

# Raise error if policy has invalid Github links in datasources
test = policy_bad_github_datasources?(file); failures << test if test
# Raise error if policy has outdated links
test = policy_outdated_links?(file); failures << test if test

# Raise warning if policy has any datasources using http instead of https
test = policy_http_connections?(file); warnings << test if test
Expand Down
4 changes: 4 additions & 0 deletions cost/flexera/cco/budget_alerts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.6.1

- Updated policy to use internal Flexera API for generating charts. Policy functionality is unchanged.

## v2.6

- Updated policy metadata to make it more clear what Flexera service the policy is for
Expand Down
4 changes: 2 additions & 2 deletions cost/flexera/cco/budget_alerts/budget_alert.pt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ category "Cost"
tenancy "single"
default_frequency "daily"
info(
version: "2.6",
version: "2.6.1",
provider: "Flexera",
service: "Cloud Cost Optimization",
policy_set: "Cloud Cost Optimization",
Expand Down Expand Up @@ -610,7 +610,7 @@ policy "budget_alert" do
### Cost Metric: {{ parameters.param_cost_metric }}
### Budget Alert Type: {{ parameters.param_type }}
### Monthly Spend for {{ data.monthYear }}
![Spending Overview Chart](https://image-charts.com/chart?{{ data.chartType }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartImage }}&{{ data.chartColor }}&{{ data.chartLebel }}&{{ data.chartYAxisLebel }}&{{ data.chartYAxis }}&{{ data.chartLebelPosition }}&{{data.chartDataAutoScale}}&{{data.chartDataValue}}&{{ data.chartTitle }})
![Spending Overview Chart](https://api.image-charts-auth.flexeraeng.com/ic-function?rs_org_id={{ rs_org_id }}&rs_project_id={{ rs_project_id }}&{{ data.chartType }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartImage }}&{{ data.chartColor }}&{{ data.chartLebel }}&{{ data.chartYAxisLebel }}&{{ data.chartYAxis }}&{{ data.chartLebelPosition }}&{{data.chartDataAutoScale}}&{{data.chartDataValue}}&{{ data.chartTitle }})
EOS
escalate $esc_budget_alert
check lt(val(data,"total"),prod($param_monthly_budget,div($param_threshold_percentage,100)))
Expand Down
4 changes: 4 additions & 0 deletions cost/flexera/cco/budget_v_actual/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.4.1

- Updated policy to use internal Flexera API for generating charts. Policy functionality is unchanged.

## v2.4

- Updated policy metadata to make it more clear what Flexera service the policy is for
Expand Down
4 changes: 2 additions & 2 deletions cost/flexera/cco/budget_v_actual/monthly_budget_v_actual.pt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ category "Cost"
tenancy "single"
default_frequency "daily"
info(
version: "2.4",
version: "2.4.1",
provider: "Flexera",
service: "Cloud Cost Optimization",
policy_set: "Cloud Cost Optimization",
Expand Down Expand Up @@ -390,7 +390,7 @@ policy "policy_scheduled_report" do
# {{ data.currentMonthName }} {{ data.currentYear }} Monthly Actual v. Budgeted Spend Report
## Org: {{ rs_org_name }} (Org ID: {{ rs_org_id }})
## Billing Center(s): {{ data.billingCenters }}
![Actual v. Monthly Cost Report](https://image-charts.com/chart?{{ data.chartType }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartLabels }}&{{ data.chartAxis }}&{{ data.chartAxisFormat }} "Actual v. Monthly Cost Report")
![Actual v. Monthly Cost Report](https://api.image-charts-auth.flexeraeng.com/ic-function?rs_org_id={{ rs_org_id }}&rs_project_id={{ rs_project_id }}&{{ data.chartType }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartLabels }}&{{ data.chartAxis }}&{{ data.chartAxisFormat }} "Actual v. Monthly Cost Report")
### For more detailed cost information, visit [Optima](https://analytics.rightscale.com/orgs/{{ rs_org_id }}/dashboard).
For more information on this report, please view the [README](https://github.com/flexera-public/policy_templates/tree/master/cost/flexera/cco/budget_v_actual).
___
Expand Down
4 changes: 4 additions & 0 deletions cost/flexera/cco/budget_v_actual_spend_report/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.5.1

- Updated policy to use internal Flexera API for generating charts. Policy functionality is unchanged.

## v2.5

- Updated policy metadata to make it more clear what Flexera service the policy is for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ category "Cost"
tenancy "single"
default_frequency "daily"
info(
version: "2.5",
version: "2.5.1",
provider: "Flexera",
service: "Cloud Cost Optimization",
policy_set: "Cloud Cost Optimization"
Expand All @@ -25,6 +25,7 @@ parameter "param_budget_name_id" do
description "Provide the name or id of a Budget"
min_length 1
constraint_description "Budget Name or ID is a required field"
# No default value, user input required
end

parameter "param_filter" do
Expand All @@ -40,7 +41,7 @@ parameter "param_unbudgeted" do
category "Policy Settings"
label "Unbudgeted spend"
description "Specify whether to consider or ignore spend that was not included in the initial budget planning."
allowed_values "Include unbudgeted spend","Exclude unbudgeted spend"
allowed_values "Include unbudgeted spend", "Exclude unbudgeted spend"
default "Include unbudgeted spend"
end

Expand Down Expand Up @@ -107,22 +108,22 @@ datasource "ds_currency_code" do
request do
auth $auth_flexera
host rs_optima_host
path join(["/bill-analysis/orgs/",rs_org_id,"/settings/currency_code"])
path join(["/bill-analysis/orgs/", rs_org_id, "/settings/currency_code"])
header "Api-Version", "0.1"
header "User-Agent", "RS Policies"
end
result do
encoding "json"
field "id", jmes_path(response,"id")
field "value", jmes_path(response,"value")
field "id", jmes_path(response, "id")
field "value", jmes_path(response, "value")
end
end

datasource "ds_get_dimensions" do
request do
auth $auth_flexera
host rs_optima_host
path join(["/bill-analysis/orgs/",rs_org_id,"/costs/dimensions"])
path join(["/bill-analysis/orgs/", rs_org_id, "/costs/dimensions"])
header "Api-Version", "0.1"
header "User-Agent", "RS Policies"
end
Expand Down Expand Up @@ -176,19 +177,19 @@ datasource "ds_budgets" do
request do
auth $auth_flexera
host val($ds_flexera_api_hosts, 'flexera')
path join(["/finops-analytics/v1/orgs/",rs_org_id,"/budgets"])
path join(["/finops-analytics/v1/orgs/", rs_org_id, "/budgets"])
header "Api-Version", "1.0"
header "User-Agent", "RS Policies"
end
result do
encoding "json"
collect jmes_path(response, "values[*]") do
field "id", jmes_path(col_item,"id")
field "name", jmes_path(col_item,"name")
field "metric", jmes_path(col_item,"metric")
field "dimensions", jmes_path(col_item,"dimensions")
field "segments", jmes_path(col_item,"segments")
field "budgetYearMonths", jmes_path(col_item,"yearMonths")
field "id", jmes_path(col_item, "id")
field "name", jmes_path(col_item, "name")
field "metric", jmes_path(col_item, "metric")
field "dimensions", jmes_path(col_item, "dimensions")
field "segments", jmes_path(col_item, "segments")
field "budgetYearMonths", jmes_path(col_item, "yearMonths")
end
end
end
Expand Down Expand Up @@ -220,26 +221,26 @@ end
datasource "ds_reports" do
iterate $ds_filtered_budgets
request do
run_script $js_reports, $ds_flexera_api_hosts, $param_unbudgeted, iter_item, rs_org_id
run_script $js_reports, iter_item, $ds_flexera_api_hosts, $param_unbudgeted, rs_org_id
end
result do
encoding "json"
collect jmes_path(response,"values[*]") do
collect jmes_path(response, "values[*]") do
field "b_id", val(iter_item, "id")
field "name", val(iter_item, "name")
field "yearMonths", val(iter_item, "budgetYearMonths")
field "dimensionsIDs", val(iter_item, "dimensions")
field "metric", val(iter_item, "metric")
field "timestamp", jmes_path(col_item,"timestamp")
field "dimensions", jmes_path(col_item,"dimensions")
field "budgetAmount", jmes_path(col_item,"metrics.budgetAmount")
field "spendAmount", jmes_path(col_item,"metrics.spendAmount")
field "timestamp", jmes_path(col_item, "timestamp")
field "dimensions", jmes_path(col_item, "dimensions")
field "budgetAmount", jmes_path(col_item, "metrics.budgetAmount")
field "spendAmount", jmes_path(col_item, "metrics.spendAmount")
end
end
end

script "js_reports", type: "javascript" do
parameters "ds_flexera_api_hosts", "unbudgeted", "budget", "org"
parameters "budget", "ds_flexera_api_hosts", "param_unbudgeted", "rs_org_id"
result "request"
code <<-EOS
function fmtDate(yearMonth) {
Expand All @@ -254,10 +255,10 @@ script "js_reports", type: "javascript" do
auth: "auth_flexera",
host: ds_flexera_api_hosts["flexera"],
verb: "GET",
path: "/finops-analytics/v1/orgs/" + org + "/budgets/" + budget.id + "/report",
path: "/finops-analytics/v1/orgs/" + rs_org_id + "/budgets/" + budget.id + "/report",
query_params: {
"dimensions": budget.dimensions || [],
"filter": unbudgeted == "Include unbudgeted spend" ? "" : "budgeted eq true",
"filter": param_unbudgeted == "Include unbudgeted spend" ? "" : "budgeted eq true",
"startAt": fmtDate(budget.start_date),
"endAt": fmtDate(endAt.getTime()),
},
Expand All @@ -270,7 +271,7 @@ script "js_reports", type: "javascript" do
end

datasource "ds_aggregated_report" do
run_script $js_aggregated_report, $ds_reports, $ds_currency_code, $ds_currency_reference, $ds_dimensions, $ds_filters, $param_budget_name_id, f1_app_host
run_script $js_aggregated_report, $ds_reports, $ds_currency_code, $ds_currency_reference, $ds_dimensions, $ds_filters, $param_budget_name_id, f1_app_host
end

script "js_aggregated_report", type: "javascript" do
Expand Down Expand Up @@ -441,7 +442,7 @@ policy "pol_budget_alert" do
- {{parameters.param_budget_name_id}}
\n
EOS
check eq(size(val(data, "invalid")),0)
check eq(size(val(data, "invalid")), 0)
escalate $esc_budget_alert
end

Expand All @@ -463,13 +464,13 @@ EOS
{{ end }}
{{end}}
![Budget vs Actual Cost Report](https://image-charts.com/chart?{{ data.chartType }}&{{ data.chartFormat }}&{{ data.chartAxVis }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartLabels }}&{{ data.chartAxis }}&{{ data.chartScaling }}&{{ data.chartColors }} "Budget vs Actual Cost Report")
![Budget vs Actual Cost Report](https://api.image-charts-auth.flexeraeng.com/ic-function?rs_org_id={{ rs_org_id }}&rs_project_id={{ rs_project_id }}&{{ data.chartType }}&{{ data.chartFormat }}&{{ data.chartAxVis }}&{{ data.chartData }}&{{ data.chartSize }}&{{ data.chartLabels }}&{{ data.chartAxis }}&{{ data.chartScaling }}&{{ data.chartColors }} "Budget vs Actual Cost Report")
[Link to budget report in Flexera One](https://{{with index data.reportData 0}}{{ .host }}{{end}}/orgs/{{ rs_org_id }}/optima/budgets/{{with index data.reportData 0}}{{ .b_id }}{{end}})
*Please note: The chart in the incident reflects the selected filters. However, the budget dashboard via hyperlink displays the overall budget without filters applied.*
EOS
check eq(size(val(data, "reportData")),0)
check eq(size(val(data, "reportData")), 0)
escalate $esc_budget_alert
export "reportData" do
field "monthYear" do
Expand Down
4 changes: 4 additions & 0 deletions cost/flexera/cco/scheduled_reports/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3.4.1

- Updated policy to use internal Flexera API for generating charts. Policy functionality is unchanged.

## v3.4

- Fixed issue where filter would not work correctly if `Month` was selected for the `Billing Term` parameter.
Expand Down
4 changes: 2 additions & 2 deletions cost/flexera/cco/scheduled_reports/scheduled_report.pt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ severity "low"
category "Cost"
default_frequency "monthly"
info(
version: "3.4",
version: "3.4.1",
provider: "Flexera",
service: "Cloud Cost Optimization",
policy_set: "Cloud Cost Optimization"
Expand Down Expand Up @@ -844,7 +844,7 @@ policy "pol_scheduled_report" do
**Billing Centers:** {{ data.billingCenters }}\\
**Filter:** {{ data.filterMessage }}\\
**Bill Currency:** {{ data.currencyCode }}\\
![Spending Overview Chart](https://image-charts.com/chart?{{ data.chartType }}&{{ data.chartSize }}&{{ data.chartTitle }}&{{ data.chartAxis }}&{{ data.chartXAxis }}&{{ data.chartAxisFormat }}&{{ data.chartData }}&{{ data.chartCategories }}&{{ data.chartColors }}&{{ data.chartKeyLocation }}&{{ data.chartExtension }} "Spending Overview Chart")
![Spending Overview Chart](https://api.image-charts-auth.flexeraeng.com/ic-function?rs_org_id={{ rs_org_id }}&rs_project_id={{ rs_project_id }}&{{ data.chartType }}&{{ data.chartSize }}&{{ data.chartTitle }}&{{ data.chartAxis }}&{{ data.chartXAxis }}&{{ data.chartAxisFormat }}&{{ data.chartData }}&{{ data.chartCategories }}&{{ data.chartColors }}&{{ data.chartKeyLocation }}&{{ data.chartExtension }} "Spending Overview Chart")
### For more detailed cost information, see [Dashboards](https://{{ data.domain }}/orgs/{{ rs_org_id }}/optima/dashboards) or [Tabular View](https://{{ data.domain }}/orgs/{{ rs_org_id }}/optima/tabular-view).
For more information on this report, please view the [README](https://github.com/flexera-public/policy_templates/tree/master/cost/flexera/cco/scheduled_reports).
EOS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v2.0.0

- Deprecated: This policy is no longer being updated.
- Updated policy to use internal Flexera API for generating charts. Policy functionality is unchanged.
- Code cleanup to bring it up to standard
- Policy now requires a valid Flexera credential

## v1.6

- Updated policy metadata to make it more clear what Flexera service the policy is for
Expand Down
31 changes: 17 additions & 14 deletions cost/flexera/cco/scheduled_reports_with_estimates/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Scheduled Report with Estimates

## What it does
## Deprecated

This policy is no longer being updated.

## What It Does

This policy allows you to set up scheduled reports that will provide summaries of cloud cost across all resources in the billing centers you specify as well as estimated costs for the next 3 months, delivered to any email addresses you specify. The policy will report the following:

## The Data Provided
### The Data Provided

Chart of the previous 6 months of utilization based on whichever Reporting Dimension you select (only bill data and RightScale-generated dimensions are supported).
Daily Average - Weekly: Daily average costs calculated from Monday of the previous week through today. Daily Average - Monthly: Daily average costs calculated from the 1st of the previous month through today. Previous - Weekly: Total costs during previous full week (Monday-Sunday).
Expand All @@ -18,7 +22,7 @@ We recommend running this policy on a weekly cadence and applying it to your mas
Note 1: The last 3 days of data in the current week or month will contain incomplete data.
Note 2: The account you apply the policy to is unimportant as Optima metrics are scoped to the Org.

## Cost Metrics
### Cost Metrics

There are four cost metrics to choose from.

Expand All @@ -27,24 +31,23 @@ There are four cost metrics to choose from.
- Unamortized Blended - One-time and upfront costs are shown at the time of purchase. (AWS Only) Saving from reserved instances are shared equally by all matching instances in all accounts.
- Amortized Blended - One-time and upfront costs are spread evenly over the term of the item purchased. (AWS Only) Saving from reserved instances are shared equally by all matching instances in all accounts.

## Functional Details

The policy leverages the RightScale APis to report on billing data and send an email report

### Input Parameters

This policy has the following input parameters required when launching the policy.

- Email list - Email addresses of the recipients you wish to notify
- Billing Center List - List of top level Billing Center names you want to report on. Names must be exactly as shown in Optima. Leave the field blank to report on all top level Billing Centers.
- Cost Metric - See Cost Metrics above for details on selection.
- Graph Dimension - The cost dimension to break out the cost data in the embedded bar chart image
- *Email List* - Email addresses of the recipients you wish to notify
- *Billing Center List* - List of top level Billing Center names you want to report on. Names must be exactly as shown in Optima. Leave the field blank to report on all top level Billing Centers.
- *Cost Metric* - See Cost Metrics above for details on selection.
- *Graph Dimension* - The cost dimension to break out the cost data in the embedded bar chart image

## Prerequisites

### Required RightScale Roles
This Policy Template uses [Credentials](https://docs.flexera.com/flexera/EN/Automation/ManagingCredentialsExternal.htm) for authenticating to datasources -- in order to apply this policy you must have a Credential registered in the system that is compatible with this policy. If there are no Credentials listed when you apply the policy, please contact your Flexera Org Admin and ask them to register a Credential that is compatible with this policy. The information below should be consulted when creating the credential(s).

This policy requires permissions to access RightScale resources (Optima). Before applying this policy add the following roles to the user applying the policy. The roles should be applied to all Accounts where the policy will run or the Organization. For more information on modifying roles visit the Governance Docs
- [**Flexera Credential**](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm) (*provider=flexera*) which has the following roles:
- `billing_center_viewer`

- Optima - billing_center_viewer
The [Provider-Specific Credentials](https://docs.flexera.com/flexera/EN/Automation/ProviderCredentials.htm) page in the docs has detailed instructions for setting up Credentials for the most common providers.

### Supported Clouds

Expand Down
Loading

0 comments on commit 44a5ecc

Please sign in to comment.