Conversation
ar
reviewed
Feb 6, 2026
ar
reviewed
Feb 6, 2026
|
|
||
| // Custom tags are added to the Meter. | ||
| // Syntax: comma/space separated entries of the form "tag:value" or just "tag" . | ||
| var envTags = Environment.get("${"+ENV_CHANNEL_TAGS+"}", DEFAULT_TAGS); |
Member
There was a problem hiding this comment.
If possible, don't use Environment directly, go through Configuration.
ar
reviewed
Feb 6, 2026
ar
reviewed
Feb 6, 2026
ar
reviewed
Feb 6, 2026
ar
reviewed
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a few issues with the current genration of metrics counters and metrics events for the "channel set":
BaseChannel,ChannelAdaptor,QServeretc.At the same time, the previously hardcoded msg counter metrics, are now configurable by means of a new interface and class:
A thorough
ISOMsgCounterTestis included.The PR includes some features:
BaseChannelhas a single reference to anISOMsgCounterwhich wraps channel metrics configuration and recording.The old references to specific
Counter msg[In|Out]Counterwere not appropriate for metrics that vary their tag values (e.g. a newmti="xyz") because it's effectively a new counter in Micrometer, that was overridding the old reference, and in the case ofQServerthat reference was alwaysnull. This also a bit incorrect when removing meters because only the most-recent one, at best. would be removed.The metrics are now generated at one point of code only: the
BaseChannelclass in itssend()andreceive()methods.The default, zero-config option behaves the same as before, generating simple counter metrics like
jpos_isomsg_total{name="some-channel",direction="in",mti="2110",type="client"} 6802.0So if you do nothing with your current system, it will keep working as it is already doing.
But now, explicit configurable counters can be attached to a channel, either programmatically or through xml in the
<channel>configuration ofChannelAdaptorandQServer.The
ChannelAdaptor#newChannel()parser was leveraged to recognize the new<metrics>element. This is useful becausenewChannel()is used by bothChannelAdaptorandQServerso it's a single point of code to do this.Global defaults for valid tags, and tag values taken from isofields (read more below). These global tags are configurable through env variables, and the defaults are the zero-config ones maitining current behavior.
ISOMsgCounterkeep track of all their counters and unregisters (remove) them correctly upon request, such as when theChannelAdaptororQServerare being stopped and undeployed.Default tags
Prometheus mandates that all metrics of the same name must have the same set of tags/labels.
If someone attempts to create/register a new
Meterwith a pre-existing name, but with a different set of tag keys, the returnedMeterwill work, but it will "almost silently" fail to register for scraping by Prometheus. It's an issue very difficult to detect programmatically, and it was fixed in PR #671 by throwing an exception.(Note: the invariant refers to the tag keys, not their values which can obviously vary)
Still, some effort was done into having "global default tags" that all channel counters can automatically and safely use. At the same time, they can be configured through env vars, and also custom counter names can be used, so that a specific channel using a custom counter name (different from the default
jpos.isomsg) is free to use its own set of tags.The env variables, and their defaults are
These refer just to the tag key, some of the values will be set dynamically for every
ISOMSgrecorded.The
fieldstags are supposed to take their values from specificISOMsgfields with a syntax explained below.Configuration
There are several ways to configure msg counter metrics in a channel through XML.
1) do nothing
This is the zero-config version. Your current configurations will continue to generate counters as explained above.
2) "none"
This effectively turns off isomsg counting for that channel, maybe saving some CPU cycles, Prometheus scraping, etc.
3) Specific "class"
In case you want to get creative with your counters 😉
4) Customizable "counter"
This "counter" type will use the
ISOMsgCounterimplementation ofISOMsgMetrics.It will generate metrics with the specific Prometheus labels:
my_tag="my_value"-- static value in this caseitc="2100.00"--itcis an alias that computes MTI + ProcessingCode(txn type) + other optionals like function and reason code)rc="0000"--rcis an alias for the value of field 39, but in this case I used explicit syntax)scheme="visa"-- generate theschemetag, with its value taken from field 113.66 in case of jPOS-CMFNow, of course this will fail with
ConfigurationExceptionbecause none of those tags are "recognized" in the default values formetrics.channel.tagsandmetrics.channel.fields.So, if you want to use custom tags for your metrics, you have two options
1)you must configure those variables with the desired
tagsand isofield tags, and they will become globally available.2) You can give your particular counter a different name such as
And you will get Prometheus serving such as
A couple of notes:
direction,type, andnamewill always be added because they are donde by the internal channel configuration. Even if you configure them in the XML such asdirection:upthe value will be overwritten when the metric is recorded.rcwithout making field 39 explicit. Also notice how I used the expressionttt:itcinstead of justitc. This means "take the value using alias itc for the isomsg field logic, but give it the tag namettt.Final notes
Grafana dashboards and operational assumptions
The standard jPOS Grafana panels assume the default metrics configuration provided by jPOS, including metric names and label keys. Although customers are free to customize or extend metric generation, the jPOS team relies on the default counters and labels for baseline system monitoring, troubleshooting, and support. For this reason, we recommend preserving the default metrics and labels, even when additional custom metrics are introduced.
Metrics cardinality
Care must be taken to keep metric cardinality under control. Adding high-cardinality labels can significantly impact Prometheus performance and resource usage. The default jPOS metrics are designed to remain low-cardinality, and any customization should preserve this property whenever possible.