095f572d4a
* Fix `kuma_sd` targetgroup reporting (#9157) * Bundle all xDS targets into a single group Signed-off-by: austin ce <austin.cawley@gmail.com> * Snapshot in-memory chunks on shutdown for faster restarts (#7229) Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com> * Rename links Signed-off-by: Levi Harrison <git@leviharrison.dev> * Remove Individual Data Type Caps in Per-shard Buffering for Remote Write (#8921) * Moved everything to nPending buffer Signed-off-by: Levi Harrison <git@leviharrison.dev> * Simplify exemplar capacity addition Signed-off-by: Levi Harrison <git@leviharrison.dev> * Added pre-allocation Signed-off-by: Levi Harrison <git@leviharrison.dev> * Don't allocate if not sending exemplars Signed-off-by: Levi Harrison <git@leviharrison.dev> * Avoid deadlock when processing duplicate series record (#9170) * Avoid deadlock when processing duplicate series record `processWALSamples()` needs to be able to send on its output channel before it can read the input channel, so reads to allow this in case the output channel is full. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * processWALSamples: update comment Previous text seems to relate to an earlier implementation. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Optimise WAL loading by removing extra map and caching min-time (#9160) * BenchmarkLoadWAL: close WAL after use So that goroutines are stopped and resources released Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * BenchmarkLoadWAL: make series IDs co-prime with #workers Series are distributed across workers by taking the modulus of the ID with the number of workers, so multiples of 100 are a poor choice. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * BenchmarkLoadWAL: simulate mmapped chunks Real Prometheus cuts chunks every 120 samples, then skips those samples when re-reading the WAL. Simulate this by creating a single mapped chunk for each series, since the max time is all the reader looks at. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Fix comment Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Remove series map from processWALSamples() The locks that is commented to reduce contention in are now sharded 32,000 ways, so won't be contended. Removing the map saves memory and goes just as fast. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * loadWAL: Cache the last mmapped chunk time So we can skip calling append() for samples it will reject. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Improvements from code review Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Full stops and capitals on comments Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Cache max time in both places mmappedChunks is updated Including refactor to extract function `setMMappedChunks`, to reduce code duplication. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Update head min/max time when mmapped chunks added This ensures we have the correct values if no WAL samples are added for that series. Note that `mSeries.maxTime()` was always `math.MinInt64` before, since that function doesn't consider mmapped chunks. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * Split Go and React Tests (#8897) * Added go-ci and react-ci Co-authored-by: Julien Pivotto <roidelapluie@inuits.eu> Signed-off-by: Levi Harrison <git@leviharrison.dev> * Remove search keymap from new expression editor (#9184) Signed-off-by: Julius Volz <julius.volz@gmail.com> Co-authored-by: Austin Cawley-Edwards <austin.cawley@gmail.com> Co-authored-by: Levi Harrison <git@leviharrison.dev> Co-authored-by: Julien Pivotto <roidelapluie@inuits.eu> Co-authored-by: Bryan Boreham <bjboreham@gmail.com> Co-authored-by: Julius Volz <julius.volz@gmail.com> |
||
---|---|---|
.. | ||
public | ||
src | ||
.eslintrc.json | ||
.gitignore | ||
package.json | ||
README.md | ||
tsconfig.json | ||
yarn.lock |
Working with the React UI
This file explains how to work with the React-based Prometheus UI.
Introduction
The React-based Prometheus UI was bootstrapped using Create React App, a popular toolkit for generating React application setups. You can find general information about Create React App on their documentation site.
Instead of plain JavaScript, we use TypeScript to ensure typed code.
Development environment
To work with the React UI code, you will need to have the following tools installed:
- The Node.js JavaScript runtime.
- The Yarn package manager.
- Recommended: An editor with TypeScript, React, and ESLint linting support. See e.g. Create React App's editor setup instructions. If you are not sure which editor to use, we recommend using Visual Studio Code. Make sure that the editor uses the project's TypeScript version rather than its own.
NOTE: When using Visual Studio Code, be sure to open the web/ui/react-app
directory in the editor instead of the root of the repository. This way, the right ESLint and TypeScript configuration will be picked up from the React workspace.
Installing npm dependencies
The React UI depends on a large number of npm packages. These are not checked in, so you will need to download and install them locally via the Yarn package manager:
yarn
Yarn consults the package.json
and yarn.lock
files for dependencies to install. It creates a node_modules
directory with all installed dependencies.
NOTE: Remember to change directory to web/ui/react-app
before running this command and the following commands.
Running a local development server
You can start a development server for the React UI outside of a running Prometheus server by running:
yarn start
This will open a browser window with the React app running on http://localhost:3000/. The page will reload if you make edits to the source code. You will also see any lint errors in the console.
Due to a "proxy": "http://localhost:9090"
setting in the package.json
file, any API requests from the React UI are proxied to localhost
on port 9090
by the development server. This allows you to run a normal Prometheus server to handle API requests, while iterating separately on the UI.
[browser] ----> [localhost:3000 (dev server)] --(proxy API requests)--> [localhost:9090 (Prometheus)]
Running tests
Create React App uses the Jest framework for running tests. To run tests in interactive watch mode:
yarn test
To generate an HTML-based test coverage report, run:
CI=true yarn test --coverage
This creates a coverage
subdirectory with the generated report. Open coverage/lcov-report/index.html
in the browser to view it.
The CI=true
environment variable prevents the tests from being run in interactive / watching mode.
See the Create React App documentation for more information about running tests.
Linting
We define linting rules for the ESLint linter. We recommend integrating automated linting and fixing into your editor (e.g. upon save), but you can also run the linter separately from the command-line.
To detect and automatically fix lint errors, run:
yarn lint
This is also available via the react-app-lint-fix
target in the main Prometheus Makefile
.
Building the app for production
To build a production-optimized version of the React app to a build
subdirectory, run:
yarn build
NOTE: You will likely not need to do this directly. Instead, this is taken care of by the build
target in the main Prometheus Makefile
when building the full binary.
Integration into Prometheus
To build a Prometheus binary that includes a compiled-in version of the production build of the React app, change to the root of the repository and run:
make build
This installs npm dependencies via Yarn, builds a production build of the React app, and then finally compiles in all web assets into the Prometheus binary.