A few months ago, I shared the Eureka moment! I had when I realized how much easier (and less stressful) my earlier career as a developer would have been if I’d had Kosli. Tl;dr - I thought I’d broken critical functionality of our SW with effects seen nationwide and was understandably stressed about it. Was it my change that broke it? I had no idea. But if I’d had Kosli I could’ve just gone to app.kosli.com and everything would have been clear right away.
When you use Kosli to report your artifacts, deployments and environments, you create a database of your development process that is full of all kinds of useful information. Well, it seems like a no-brainer to implement a way to query that database :) So, without further ado, let me introduce you to:
The kosli search command
My colleagues and I use different source code editors for much more than just editing the code. I can’t speak for everyone but I’m fairly sure that it’s a common practice :) We write our software, test it, build it, and publish it - all from within one window, all available at our fingertips. And all the information about artifacts, deployments and environments that you stored in Kosli is now available at your fingertips too.
Our CLI is regularly used in CI pipelines, or via cron jobs - that’s a nice way to handle the reporting. But you can use the CLI to query Kosli and learn all there is to know about your code and its status. The only thing you need to provide is the sha of the commit you’re interested in - which you can usually get from within your editor.
Ok, Let’s search!
The reason for your search doesn’t always have to be as dramatic as “did I break prod?”. Quite the opposite! Once you implement a new feature you may simply want to know if it has been deployed to an environment, e.g. staging, so you can click around and see how it works. Or, for a more glorious example, you may want to know if you’re the one who fixed the prod :)
Yesterday I introduced some changes to our backend and now I am curious to see if they have been successfully built and maybe even deployed. I can use `git log` to find the sha of the commit I am interested in:
$ git log --oneline 3caa362b (HEAD -> master, origin/master, origin/HEAD) Show richer git info: add branch and timestamp #477 c001f322 Gunicorn: fix test coverage problem that fails server start-up on staging
And then I use it to search:
$ kosli search 3caa362 Search result resolved to commit 3caa362b091d7e53dbcfc75389f3a2564dc2a88d Name: 772819027869.dkr.ecr.eu-central-1.amazonaws.com/merkely:3caa362 Fingerprint: 9e9dcfb300931ab8033430b60fc85259c43b7a45cdd34fef8b0473fff5e7c413 Has provenance: true Pipeline: merkely Git commit: 3caa362b091d7e53dbcfc75389f3a2564dc2a88d Commit URL: https://github.com/kosli-dev/server/commit/3caa362b091d7e53dbcfc75389f3a2564dc2a88d Build URL: https://github.com/kosli-dev/server/actions/runs/3513119469 Compliance state: COMPLIANT Exited from environments: azure-staging-aws#1936, staging-aws#2414 History: Artifact created Mon, 21 Nov 2022 10:30:33 CET unit-test evidence received Mon, 21 Nov 2022 10:31:58 CET unit-test-coverage evidence received Mon, 21 Nov 2022 10:31:59 CET integration-test evidence received Mon, 21 Nov 2022 10:32:33 CET integration-test-coverage evidence received Mon, 21 Nov 2022 10:32:34 CET Deployment #5558 to staging-aws environment Mon, 21 Nov 2022 11:03:54 CET Deployment #5559 to azure-staging-aws environment Mon, 21 Nov 2022 11:03:54 CET Started running in staging-aws#2412 environment Mon, 21 Nov 2022 11:05:22 CET Started running in azure-staging-aws#1933 environment Mon, 21 Nov 2022 11:05:24 CET Scaled up from 1 to 2 in staging-aws#2413 environment Mon, 21 Nov 2022 11:06:22 CET Scaled up from 1 to 2 in azure-staging-aws#1934 environment Mon, 21 Nov 2022 11:06:24 CET Scaled down from 2 to 1 in azure-staging-aws#1935 environment Mon, 21 Nov 2022 11:52:24 CET No longer running in staging-aws#2414 environment Mon, 21 Nov 2022 11:53:22 CET No longer running in azure-staging-aws#1936 environment Mon, 21 Nov 2022 11:53:24 CET
What does the output above tell me? There is indeed an artifact that was built using my commit. I can also see the History - all the events related to that artifact that have been recorded by Kosli. I can see all the evidence, reported deployments, and if and when it was first reported to be actually running in our environments.
How does it answer my question?
It tells me it was deployed to our staging environments:
Exited from environments: azure-staging-aws#1936, staging-aws#2414
It’s not running there anymore, but unless there was a rollback I can be fairly certain my changes are still included in a newer artifact that is running there now. What if fairly certain is not enough? Let’s check what’s running in the staging-aws environment now:
$ kosli environment get staging-aws COMMIT ARTIFACT PIPELINE RUNNING_SINCE REPLICAS N/A Name: 772819027869.dkr.ecr.eu-central-1.amazonaws.com/adot:v0.21.0 N/A 15 hours ago 2 Fingerprint: 8cbf709ad4c4eb3d5edcd33a806b9d2903d48945a897047c6ab184d2445dd6c3 9a158e2 Name: 772819027869.dkr.ecr.eu-central-1.amazonaws.com/merkely:9a158e2 merkely 15 hours ago 2 Fingerprint: b8f43e84d0764f3540264dcf0c09cefb626afba08755897bb235f7c17d845276
I can see which version of our app is currently running, and with the provided fingerprint (using pipeline name followed by ’@’ and the fingerprint) or using commit sha (using pipeline name followed by ‘:’ and the sha) I can dig into its details:
$ kosli artifact get merkely@b8f43e84d0764f3540264dcf0c09cefb626afba08755897bb235f7c17d845276 Name: 772819027869.dkr.ecr.eu-central-1.amazonaws.com/merkely:9a158e2 Pipeline: merkely Fingerprint: b8f43e84d0764f3540264dcf0c09cefb626afba08755897bb235f7c17d845276 Created on: Mon, 21 Nov 2022 20:40:39 CET • 15 hours ago Git commit: 9a158e2cc1165eafa9cd765725b089e4efb35c42 Commit URL: https://github.com/kosli-dev/server/commit/9a158e2cc1165eafa9cd765725b089e4efb35c42 Build URL: https://github.com/kosli-dev/server/actions/runs/3517568107 State: COMPLIANT Running in environments: azure-staging-aws#1944, staging-aws#2419 History: Artifact created Mon, 21 Nov 2022 20:40:39 CET unit-test evidence received Mon, 21 Nov 2022 20:42:28 CET unit-test-coverage evidence received Mon, 21 Nov 2022 20:42:30 CET integration-test evidence received Mon, 21 Nov 2022 20:43:11 CET integration-test-coverage evidence received Mon, 21 Nov 2022 20:43:13 CET Deployment #5564 to azure-staging-aws environment Mon, 21 Nov 2022 20:44:08 CET Deployment #5565 to staging-aws environment Mon, 21 Nov 2022 20:44:16 CET Started running in azure-staging-aws#1941 environment Mon, 21 Nov 2022 20:45:24 CET Started running in staging-aws#2419 environment Mon, 21 Nov 2022 20:46:22 CET Scaled up from 1 to 2 in azure-staging-aws#1942 environment Mon, 21 Nov 2022 20:46:23 CET Scaled down from 2 to 1 in azure-staging-aws#1943 environment Tue, 22 Nov 2022 07:48:24 CET Scaled up from 1 to 2 in azure-staging-aws#1944 environment Tue, 22 Nov 2022 07:49:24 CET
Here the output is a bit different because the artifact is still running in some environments:
Running in environments: azure-staging-aws#1944, staging-aws#2419
I can also see the sha of the commit used to build it, so I can easily browse the code at that point, or diff it with my original commit to see if the part of the code I’m interested in is still there.
Checking to see if my code changes are “live” is just one reason I would use search or some of the other Kosli commands. As a person with an infrastructure focus I can start with
kosli environment get command to check which artifacts are running in an environment, and I can use
kosli search or
kosli artifact get to learn more about each artifact.
As a developer, I may simply want to check where my commit is in the development process. Did it pass the unit test? Is coverage ok? What about the integration test? As long as you keep reporting to Kosli you will have all of this information available at your fingertips. You don’t need to search for a CI run for a given commit, or access an environment to see what’s running there (which is sometimes tricky or even impossible without special permissions).
Would you like to try it out?
kosli search command can be enough to get all the information you need, but it can also be a first step in a journey that’s made possible with other commands. You can learn all about them by visiting the Search section of our documentation.
If you’re already reporting to Kosli, or you work for a company where Kosli is used, you are two steps away from being able to browse the data on your machine. And if you do not use Kosli yet, but want to see how it works in practice, you can use our demo organization ´cyber-dojo´ to follow examples from the Search section.
Step 1: Install CLI on your machine
All the information about CLI installation is available in our documentation
If you already have kosli CLI installed, make sure it’s updated to the latest version to enable the search feature.
Step 2: Configure your environment
Setup your API token (available under your Profile at app.kosli.com) and the organization as environment variables, so Kosli knows what you want to look at and that you’re authorized to do it:
$ export KOSLI_API_TOKEN=<your token> $ export KOSLI_OWNER=<organization name>
And start searching!
Try it out and let us know what you think. Kosli Community slack workspace is the best place to leave feedback or ask for support.