Test Observability & Engineering effectiveness
“Engineering Effectiveness” has been a central topic of discussion and focus this year
Testing across all interfaces, platforms and architectural components
Product test engineering, Shift-Left testing and digital transformation
Automate tests across all interfaces, platforms and horizontal scaling
Generative AI, Flutter, React Native, Micro-services, Micro-frontends & TestOps
Measure and enhance the efficiency & effectiveness of testing teams & solutions
Offshore Testing Setup as a Service, platform engineering and Modernisation
How to build a Real-time Test Case Monitoring solution using logs?
any of us have heard about monitoring logs via real-time dashboards like Kibana, Grafana and etc while working with the development team. As a QA, It’s always fascinating to check the test case logs in a real-time dashboard that is easily accessible from anywhere and anytime.
Today, We will have a look at how we can have a real-time dashboard that will show us the test cases running and generating logs. This will help us to understand if there are any issues at a very early stage.
To do this we will be using the approach of ELK.
So, what is the ELK? “ELK” is the acronym for three open source projects: Elasticsearch, Logstash, and Kibana. Elasticsearch is a search and analytics engine. Logstash is a server‑side data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and then sends it to a “stash” like Elasticsearch. Kibana lets users visualize data with charts and graphs in Elasticsearch.
Note: As of now, We will be working only with Elasticsearch and Kibana.
In this blog, We will be running elasticsearch & kibana on docker as it will provide less load to the local system and is easy to configure.
Let’s run the below commands in the terminal after docker is up.
$ docker run -p 9200:9200 -p 9300:9300 — name elasticsearch -e “discovery.type=single-node” docker.elastic.co/elasticsearch/elasticsearch:7.11.1
The above command will pull elasticsearch engine image and will start the server.
Once the Elasticsearch server starts, Now hit the below command to start Kibana as Kibana will be working internally with elasticsearch to get the data.
$ docker run -p 5601:5601 — name kibana — link elasticsearch:elasticsearch docker.elastic.co/kibana/kibana:7.11.1
Once both these containers are up and running. Navigate to the below link
http://localhost:5601/
This will open Kibana Dashboard.
Now, It’s time we need to add data inside elasticsearch for indexing, It can be done with the help of API.
We will use Postman as of now to insert data in elasticsearch. (You can configure the same in the framework which will send the test case data after executing to ElasticSearch). We need to hit the endpoint with payload.
Endpoint: http://localhost:9200/example/tc1
Payload :
{
"testName": "testcase1",
"module": "Payments",
"status": "Pass"
}
When we will hit the above endpoint with the POST method, We are inserting this payload to elasticsearch under type “example” and there will multiple requests would be made and in that case, elasticsearch will save these data in the form of indexing.
Once we have pushed the data that we wanted in elasticsearch. We will not move to create a dashboard. This dashboard will keep on monitoring elasticsearch for the data that is getting pushed and will visualize the same on the dashboard.
To create a dashboard in Kibana, We first have to generate index patterns for the data coming from elasticsearch.
To create an index pattern, Hit elasticsearch URL http://localhost:9200/ navigate & click on Stack management.
Then under stack management, Click on index pattern & click on create index pattern.
Then search for the type under which we have pushed our data using the API. For this blog, “example” is the type under which we pushed our payload. Select the type and click on the next step. You can select the time field from the dropdown. Now click on create index pattern.
We are done with creating the index pattern.
Now, Let’s discover and check if we are getting the logs on kibana.
Click on the hamburger menu on the top left corner & select Discover.
Click on the filter drop-down and select the type that we had added in elasticsearch.
Now, Change the dates and click on refresh. You will see the logs that are getting generated when the test cases run.
You can also, configure the dates and times in such a way that it keeps on refreshing at regular intervals to get real-time data.
With these easy configurations, We can see what exactly is happening around when your test cases are running. Also, it becomes very easy to catch any discrepancies way before the entire execution is completed.
We can add dashboards with the same elasticsearch configurations to get the entire execution details in graphical format.
Stay tuned for my next blog on creating real-time dashboards with Kibana.
Share This Article
“Engineering Effectiveness” has been a central topic of discussion and focus this year
With us, you’re not just a part of a company; you’re part of a movement dedicated to pushing boundaries, breaking barriers, and achieving the extraordinary.
Otaku 2.0 sought to redefine the way we approach testing, celebrate the spirit of innovation, and pave the way for a brighter future in tech.