TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Custom Chart

Last modified: 20 April 2023

In addition to statistic charts generated automatically by TeamCity on the Statistics tab, it is possible to configure your own statistical charts based on the set of statistic values provided by TeamCity or values reported from a build script. In the latter case you will need to configure your build script to report custom statistical data to TeamCity.

You can view statistic values reported by the build on the Build parameters page.

Managing Custom Charts via the TeamCity Web UI



It is possible to manage custom charts using the TeamCity Web UI.

Adding Custom Charts



  • The Statistics tab for a project or build configuration provides an option to create a new chart. Note that only one build configuration can be currently added as the data source. More configurations can be added manually.

  • On the Parameters tab of the build results page, the list of Reported statistic values provides checkboxes to select the statistics type for a new project- or build-configuration-level chart.

    • A project-level chart will be added to the selected target project. The root project cannot be selected as the target.

    • A build-configuration-level chart will be added to all build configurations of the selected target project and its subprojects. Specifying the root project as the target will add the chart to all build configurations available on the server.

Modifying Custom Charts



Use the pencil Pencil icon to edit or delete a custom chart. Note that the Add Statistic Values drop-down displays all statistic values registered on the server. If you select a value non-existent in the current build configuration or project when editing a chart, the chart will not be saved.

Using the cog Cog icon, you can also configure the Y-axis settings and save them as defaults for all users.

There is a number of limitations to editing charts from the TeamCity UI.

Reordering Custom Charts



To reorder custom charts for a project/build configuration, click the Reorder button and drag-and-drop the charts to arrange them as required and apply your changes.

Managing Custom Charts Manually



To manually create custom charts to be displayed in the TeamCity web UI, configure the < >/ config/projects/ < ProjectID > /project-config.xml file. The file has the<project-extensions> element which contains all project features, including custom charts. For each chart an <extention> element is added.

Displaying Custom Chart in TeamCity Web UI



To make TeamCity display a custom chart in the web UI, update the < >/ config/projects/ < ProjectID > /project-config.xml configuration file adding a new <extention> sub-element to the <project-extensions> element.

Each extension must have a unique id in the project.

The typeattribute is set to

  • <project-graphs> for Project-level chart

  • <buildType-graphs> for Build Configuration-level chart.

Each chart is described by the <parameters> element. It must contain the < param> sub-elements with data shown in the chart in name/value pairs; the "series" parameter uses the JSON format to list series of data shown on the chart.

See the example below:

Custom build configuration-level chart in project-config.xml

This chart will be shown on Statistics tabs of the Build Configurations of the project where the project-config.xml file is located and all its subprojects. To display a chart for all Build Configurations, add it to the project-config.xml of the Root Project.

Parameters Reference



The <series> parameter uses JSON format to list series of data shown on the chart. Each series is drawn in a separate color and you can choose one or another series using a filter.

Chart Dimensions



You can set the custom chart width/height in pixels using the properties.width andproperties. height attributes for the param elements, e.g. <param name="properties.width" value="300"/>.

Chart Axis Settings



You can also customize the default axis settings for a chart via parameter names starting with properties, e.g. properties.axis.y.type

Supported properties:

Default Statistics Values Provided by TeamCity



The table below lists the predefined value providers that can be used to configure a custom chart. The values reported for each build differ depending on your build configuration settings.

You can view the all statistic values reported by the build on the Build Results | Parameters | Reported statistic values tab. For each of the values, a statistics chart is available on clicking the View Trend icon View trend.

Custom Build Metrics



If the predefined build metrics do not cover your needs, you can report custom metrics to TeamCity from your build script and use them to create a custom chart. There are two ways to report custom metrics to TeamCity:

Note that custom value keys should be unique and should not interfere with value keys predefined by TeamCity.