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

[cloudcost-exporter]: Road to open source #5

Closed
11 tasks done
Pokom opened this issue Oct 10, 2023 · 1 comment
Closed
11 tasks done

[cloudcost-exporter]: Road to open source #5

Pokom opened this issue Oct 10, 2023 · 1 comment

Comments

@Pokom
Copy link
Contributor

Pokom commented Oct 10, 2023

We reached consesnus in the cloudcost-exporter design document that we will work towards open sourcing the project with a compute module. This issue is meant to track the work necessary to see it through and communicate progress.

Tasks

Preview Give feedback
  1. the-it
  2. 1 of 1
    Pokom
  3. Pokom
  4. 2 of 2
    area/capacity good first issue
  5. the-it
  6. good first issue
    logyball
  7. good first issue
    logyball
  8. good first issue
    logyball
@Pokom Pokom transferred this issue from another repository Nov 29, 2023
Pokom added a commit that referenced this issue Apr 9, 2024
Introduces a new label `disk_type` which can be represented as
- `boot_disk`
- `persistent_volume`

The purpose of this is to help further differentiate the type of disks that are being exported. When comparing exported results, I found ~4000 disks that were not represented by `opencost`. After investigating further, these disks were specifically related to boot disks. 

The neat thing about this is we can start associated the costs of boot volumes to the team that is responsible for provisioning nodes within our k8s environments. 

- relates to #5
Pokom added a commit that referenced this issue May 2, 2024
Previously we relied upon `GO_LDFLAGS` to be passed in to get information such as the branch, revision, and version information. Another pattern we can follow is to use the existing `make build-binary` command which as all of the scripting defined for the necessary variables to build up the `GO_LDFLAGS`. In order to support this, we need `git` and `make` installed, which thankfully come bundled with the regular golang image.

Updates `VERSION` to be `git describe --tags --dirty --always` which will use the the tag information from git directly. The neat this about this command is that if you're on a branch that isn't tagged, it'll return the latest tag and append an abbreviation of the current commit which will guarantee uniqueness between branches. This will support us making "dirty" releases on main, and then when we create a new tags, we'll have an image created with that specific tag. 

To test out, I've built locally with a tag `poko-test-local`:

```
make build-image                                                                                                                                                                                                                           ~/dev/grafana/cloudcost-exporter
docker build --build-arg GO_LDFLAGS="-X github.com/prometheus/common/version.Branch=ci/update-build-binary-to-use-make -X github.com/prometheus/common/version.Version=dev-poko-test-local -X github.com/prometheus/common/version.Revision=a7db1f2 -X github.com/prometheus/common/version.BuildUser=poko@roberto -X github.com/prometheus/common/version.BuildDate=2024-05-01T17:54:56Z" -t grafana/cloudcost-exporter -t grafana/cloudcost-exporter:dev-poko-test-local .
[+] Building 22.3s (17/17) FINISHED                                                                                                                                                                                                                                                                 docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                          0.0s
 => => transferring dockerfile: 427B                                                                                                                                                                                                                                                                          0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                                                                                                              0.0s
 => [internal] load metadata for docker.io/library/golang:1.22.1                                                                                                                                                                                                                                              0.4s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                             0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                                                               0.0s
 => [build 1/6] FROM docker.io/library/golang:1.22.1@sha256:0b55ab82ac2a54a6f8f85ec8b943b9e470c39e32c109b766bbc1b801f3fa8d3b                                                                                                                                                                                  0.0s
 => FROM docker.io/library/alpine:latest                                                                                                                                                                                                                                                                      0.0s
 => [internal] load build context                                                                                                                                                                                                                                                                             0.1s
 => => transferring context: 348.99kB                                                                                                                                                                                                                                                                         0.1s
 => CACHED [build 2/6] WORKDIR /app                                                                                                                                                                                                                                                                           0.0s
 => CACHED [build 3/6] COPY [go.mod, go.sum, ./]                                                                                                                                                                                                                                                              0.0s
 => CACHED [build 4/6] RUN go mod download                                                                                                                                                                                                                                                                    0.0s
 => [build 5/6] COPY . .                                                                                                                                                                                                                                                                                      0.2s
 => [build 6/6] RUN make build-binary                                                                                                                                                                                                                                                                        20.5s
 => CACHED [stage-1 1/4] COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/                                                                                                                                                                                                         0.0s 
 => CACHED [stage-1 2/4] COPY --from=build /etc/passwd /etc/passwd                                                                                                                                                                                                                                            0.0s 
 => CACHED [stage-1 3/4] WORKDIR /root                                                                                                                                                                                                                                                                        0.0s 
 => [stage-1 4/4] COPY --from=build /app/cloudcost-exporter ./                                                                                                                                                                                                                                                0.1s 
 => exporting to image                                                                                                                                                                                                                                                                                        0.2s 
 => => exporting layers                                                                                                                                                                                                                                                                                       0.2s 
 => => writing image sha256:098a4862eaf8574964646dc1038bc832a70e61ff10a438354cd2673b4fa1c413                                                                                                                                                                                                                  0.0s
 => => naming to docker.io/grafana/cloudcost-exporter                                                                                                                                                                                                                                                         0.0s
 => => naming to docker.io/grafana/cloudcost-exporter:dev-poko-test-local 
```

When running the image locally, you'll note the version gets propogated:

```
docker run docker.io/grafana/cloudcost-exporter:dev-poko-test-local                                                                                                                                                                        ~/dev/grafana/cloudcost-exporter
2024/05/01 17:57:33 Version (version=dev-poko-test-local, branch=ci/update-build-binary-to-use-make, revision=a7db1f2)
```

- refs #5
Pokom added a commit that referenced this issue May 2, 2024
With the push to release the project publicly, I wanted to refactor the base README. For internal usages it was fine, but if it's public I think it's lacking clarity on what exactly the project is trying to solve. This is a first draft on improving the messaging about what the project is, isn't, and how to get started.

There's sections that will be sparse until we have a better story around a helm chart or other release mechanisms. IE, how to operate the thing.

- refs #5
Pokom added a commit that referenced this issue May 2, 2024
In order to better track freshness of data, this PR adds a few more operational metrics:
- `cloudcost_exporter_collector_last_scrape_time`
- `cloudcost_exporter_last_scrape_time`

The intent of these is to export in unix time the last time a scrape was performed. This can be used to alert in prometheus when the last_scrape_time was say > 60m.

This also implements in AWS the operational metrics that GCP implemented so that we have feature parity between the two. In the future it would make sense to generalize this to a common interface so that new providers do not need to implement the same metrics.

- refs #5 + #105
@Pokom
Copy link
Contributor Author

Pokom commented May 8, 2024

Completed as of Friday, May 2nd 🎉

@Pokom Pokom closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants