Skip to content

Commit

Permalink
updates cli and monitoring docs (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
RiyaRaj28 committed Jun 9, 2024
1 parent 5341c0d commit af1f41b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/docs/cli/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ title: Setup
install the package

```
npm install -g @soorajk1/stencil-cli
npm install -g @samagra-x/stencil-cli
```

## USAGE
Expand Down
6 changes: 4 additions & 2 deletions docs/docs/cli/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ title: Introduction

While developing this cli, many custom schematics were created to assist the cli in file generation.

The following new commands are available to the user if they wish to expedite a manual setup of their server
In this CLI tool, several new commands have been added to expedite the manual setup of a server environment. Let's delve deeper into each of these commands and understand how they can benefit users:

1. `service-prisma` : Creates a new `prisma.service.ts` and adds it as a provider to `app.module.ts`
2. `prisma` : Adds a sample `User` model to the `schema.prisma` file
3. `service-user` : Adds the necessary imports for `@techsavvyash/user-service` in `app.module.ts`
3. `service-user` : Adds the necessary imports for `@samagra-x/user-service` in `app.module.ts`
4. `fixtures` : Generate the docker related files along with the shell sciripts needed to run the `pre-commit` file in husky
5. `husky` : Creates the `pre-commit` file in the `.husky` folder
6. `github` : Creates a new `.github` folder and the `ISSUE_TEMPLATE` and `Workflow` subdirectory in it.
7. `devcontainer` : Generates the `devcontainer.json` in the .devcontainer directory.

Overall, these commands enhance the usability of your CLI tool by automating repetitive and error-prone tasks, enabling developers to set up their server environments quickly and efficiently. By leveraging these custom schematics, developers can focus more on writing code and less on manual setup, ultimately improving productivity and code quality which is the prime goal for this setup.

</p>
42 changes: 29 additions & 13 deletions docs/docs/monitoring/nestjs-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,37 @@ title: NestJS-Monitor

## Introduction

`stencil` comes with out of the box support for creating `grafana dashboards` automatically using custom made `NestJS Interceptors` which generate the dashboard JSONs automatically.
`stencil` offers seamless integration with NestJS to automate the creation of `Grafana dashboards`. By leveraging custom NestJS Interceptors, the platform can generate dashboard JSONs automatically, ensuring real-time monitoring and visualization of application performance metrics.

## Features
1. Automatic Grafana Panel Creation
stencil simplifies the process of creating Grafana panels. Each time a new instance of the ResponseTimeInterceptor is added to a NestJS application, stencil generates corresponding dashboard panels automatically. This feature eliminates the manual effort involved in setting up performance dashboards, allowing developers to focus on their core application logic.

1. Automatic creation of `grafana` panels.
2. Automatic updation of panel JSONs upon addition of new instances of `ResponseTimeInterceptor` in the NestJS app.
3. Each instance of `ResponseTimeInterceptor` corresponds to a new `row` in the response_times `dashboard`.
4. Each row has the following 5 panels.
- **Heatmap response times:** This is a heatmap of all the response times for a particular instance of the `ResponseTimeInterceptor`.
- **Guage for number of requests**: This gauage tells the number of requests that have arrived at each endpoint being captured by a particular instance of `ResponseTimeInterceptor`.
- **Average response time graph**: This graph gives out information about the average response time for the requests coming through the interceptor.
- **Total number of requests graph**: This graph tells the total number of requests being received at a particular point of time.
- **Number of requests by status codes graph**: This graph gives out information about the number of requests grouped by the response HTTP status codes.
2. Dynamic Panel Updates
Whenever a new ResponseTimeInterceptor instance is introduced, stencil dynamically updates the panel JSONs. This ensures that the dashboards always reflect the latest performance metrics and application changes. Each interceptor instance adds a new row to the response_times dashboard, providing granular insights into different parts of the application.

3. Detailed Performance Panels
Each row in the dashboard contains the following five panels:

- **Heatmap Response Times:** This panel visualizes the distribution of response times for requests captured by a particular ResponseTimeInterceptor instance. It provides a clear overview of performance patterns and helps identify outliers. The heatmap allows for quick identification of latency issues, and the color intensity indicates the frequency of specific response times. Additionally, it can highlight periods of high and low activity, aiding in performance tuning and resource allocation.

- **Gauge for Number of Requests:** This gauge displays the total number of requests received by each endpoint monitored by the interceptor. It offers a quick snapshot of traffic volume and endpoint activity. The gauge can indicate sudden spikes in traffic, helping in identifying potential DDoS attacks. Furthermore, it provides real-time feedback on the effectiveness of scaling policies. By monitoring the gauge, you can ensure that your endpoints handle the expected load efficiently.

- **Average Response Time Graph:** This graph tracks the average response times for requests processed by the interceptor. It helps in monitoring the overall performance and responsiveness of the application over time. Analyzing the trends in this graph can help pinpoint bottlenecks and inefficiencies in the application. The graph can also be used to measure the impact of performance optimizations. Additionally, it provides insights into how different endpoints perform under varying loads.

- **Total Number of Requests Graph:** This panel provides a timeline view of the total number of requests received at different points in time. It is useful for identifying traffic trends and peak usage periods. This information can be crucial for capacity planning and scaling decisions. The graph can also highlight seasonal or event-driven traffic patterns. Moreover, it helps in understanding user behavior and the application's usage patterns.

- **Number of Requests by Status Codes Graph:** This graph categorizes the requests based on their HTTP status codes. It offers insights into the success and failure rates of requests, helping in diagnosing issues and ensuring robust application performance. The graph can help in quickly identifying and addressing frequent errors or anomalies. It also provides a breakdown of client-side versus server-side errors. Additionally, the graph can be used to track the effectiveness of fixes and improvements over time.

To read more about how the interceptor can be used, refer [here](https://github.com/techsavvyash/nestjs-monitor#usage)
To learn more about NestJS interceptor you can refer official NestJS documentation [here](https://docs.nestjs.com/interceptors)
A small demo showcasing these `interceptors` in action can be found [here](https://drive.google.com/file/d/1KSxZdQzUU8SJmpmLHPpUSrRpnsL4aQY2/view?usp=sharing)
</p>

For additional information on NestJS interceptors, refer to the official NestJS documentation [here](https://docs.nestjs.com/interceptors)

## Demo

A small demo showcasing these `interceptors` in action can be found [here](https://drive.google.com/file/d/1KSxZdQzUU8SJmpmLHPpUSrRpnsL4aQY2/view?usp=sharing). This demonstration provides a practical example of how the interceptors work and the kind of insights they can offer.

By integrating stencil with your NestJS application, you can achieve comprehensive, automated performance monitoring with minimal effort, ensuring your application runs smoothly and efficiently.

</p>

0 comments on commit af1f41b

Please sign in to comment.