Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update slx's configs #16

Merged
merged 6 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion codebundles/rds-mysql-conn-count/runwhen-config/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,83 @@
Placeholder for runwhen platform config.
## ServiceLevelX(SLX)

Read more about [ServiceLevelX(SLX)](https://docs.runwhen.com/public/runwhen-platform/terms-and-concepts#servicelevelx-slx)

## Service Level Indicator(SLI)

Read more about [Service Level Indicator(SLI)](https://docs.runwhen.com/public/runwhen-platform/terms-and-concepts#service-level-indicator-sli)

In this SLI, we measure the reliability level of RDS MYSQL using the `aws_rds_database_connections_average{dimension_DBInstanceIdentifier="robotshopmysql"}` metric. If the connections average exceeds 30, we're likely to experience disruptions in services connected to RDS MYSQL.

### Runtime configuration details, such as:

`displayUnitsLong` and `displayUnitsShort` Display Units (Long and short): these display on the map and should be meaningful to map viewers

`intervalSeconds`: How much time will elapse between each execution of the SLI code

[`intervalStrategy`](https://docs.runwhen.com/public/runwhen-platform/feature-overview/points-on-the-map-slxs/service-level-indicators-slis/interval-strategies): Intermezzo (simply means that we run the code on an interval)

`locations`: Which RunWhen location to execute the SLI code within. RunWhen will operate many locations that exist across different computing regions. Currently, `location-01-us-west1` is available.

`codeBundle`:
- `repoUrl`: This specifies the URL of the Git repository where the code bundle is located.
- `ref`: This indicates the Git reference (such as branch or tag) to use from the repository specified in repoUrl. In this case, it's set to main, implying that the code from the main branch of the repository will be used.
- `pathToRobot`: This specifies the path within the repository where the specific Robot Framework file (sli.robot) is located.

`secretsProvided`: This parameter includes the secrets passed through the platform, allowing us to avoid committing the secrets in our SLX codes.

`servicesProvided`: Select the RunWhen Service to use for accessing services within a network. For instance, if we want to access the Prometheus endpoint, we can utilize `curl-service.shared`.

Available service binaries:

# Curl cli
- name: curl
locationServiceName: curl-service.shared

# kubectl cli
- name: kubectl
locationServiceName: kubectl-service.shared

# Google cloud cli
- name: gcloud
locationServiceName: gcloud-service.shared


### `configProvided` schema:

`PROMETHEUS_HOSTNAME`: The prometheus endpoint to perform requests against. Currently, this endpoint must be publicly exposed because RunWhen lacks a method to access internal endpoints through its runwhen-local(agent).

`QUERY`: The PromQL statement used to query metrics. In this case it's `aws_rds_database_connections_average`

`TRANSFORM`: What transform method to apply to the column data. Available options are `RAW`, `MAX`, `Average`, `Minimum`, `Sum`, `First` and `Last`. `First` and `Last` are position relative, so Last is the most recent value. Use Raw to skip transform.

`STEP`: The step interval in seconds requested from the Prometheus API.

`DATA_COLUMN`: Which column of the result data to perform aggregation on. Typically 0 is the timestamp, whereas 1 is the metric value.

`NO_RESULT_OVERWRITE`: Determine how to handle queries with no result data. Set to Yes to write a metric (specified below) or No to accept the null result.

`NO_RESULT_VALUE`: Set the metric value that should be stored when no data result is available.


## Service Level Objective(SLO)

Read more about [Service Level Objective(SLO)](https://docs.runwhen.com/public/runwhen-platform/terms-and-concepts#service-level-objective-slo)

## Automated Tasks (Runbook)

Learn more about [Task](https://docs.runwhen.com/public/runwhen-platform/terms-and-concepts#task)

Here, we're adding the `codebundles/rds-mysql-conn-count/runbook.robot` runbook to terminate the sleeping MySQL process. We're passing `MYSQL_USER`, `MYSQL_HOST`, and `PROCESS_USER` (the username of the sleeping process), while the password will be retrieved from the runwhen platform.

This runbook utilizes the `RW.Core.Import Secret` function, which instructs the platform to prompt for the `MYSQL_PASSWORD` as secret input. This approach eliminates the need to explicitly include it in our YAML file in an unsafe manner.

The `secretsProvided` parameter specifies the secrets that will be automatically added to the YAML configuration. In this case:

```
secretsProvided:
- name: MYSQL_PASSWORD
workspaceKey: MYSQL_PASSWORD
```

- `name`: Specifies the name of the secret.
- `workspaceKey`: Indicates the workspace key associated with the secret.
3 changes: 0 additions & 3 deletions codebundles/rds-mysql-conn-count/runwhen-config/runbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ codeBundle:
repoUrl: https://github.com/infracloudio/ifc-rw-codecollection
ref: main
pathToRobot: codebundles/rds-mysql-conn-count/runbook.robot
secretsProvided: []
servicesProvided:
- name: curl
locationServiceName: curl-service.shared
Expand All @@ -14,5 +13,3 @@ configProvided:
value: robotshopmysql.example.us-west-2.rds.amazonaws.com
- name: PROCESS_USER
value: shipping
- name: MYSQL_PASSWORD
value: example_pass
2 changes: 1 addition & 1 deletion codebundles/rds-mysql-conn-count/runwhen-config/slo.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
codeBundle:
repoUrl: https://github.com/runwhen-contrib/rw-public-codecollection
repoUrl: https://github.com/infracloudio/ifc-rw-codecollection
pathToYaml: codebundles/slo-default/queries.yaml
ref: main
sloSpecType: simple-mwmb
Expand Down
3 changes: 3 additions & 0 deletions codebundles/slo-default/queries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please update the RDS_MYSQL_DB_NAME to match your RDS instance name, for which we aim to establish the SLO based on aws_rds_database_connections_average metric
errorQuery: "aws_rds_database_connections_average{dimension_DBInstanceIdentifier="<RDS_MYSQL_DB_NAME>"} > 30"
totalQuery: "aws_rds_database_connections_average{dimension_DBInstanceIdentifier="<RDS_MYSQL_DB_NAME>"}"