How to block Label type fields autocomplete suggestions and other URL requests in Jira

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Admins may want to block some requests to Jira to prevent unnecessary server load or other reasons.

This article offers an alternative to block requests based on their URL by editing the urlrewrite.xml of Jira's Tomcat. Otherwise, this would be accomplished by configuring the rules on Proxies or Load Balancers.

This is particularly useful to block Label type fields autocomplete suggestions, as they tend to run for long and consume server CPU when too many records exist on the label table:

JRASERVER-73769 - Label suggestions performance grows slow linearly as Jira scales which has been fixed in Jira 10.2.0 and later

URL rewriting is best handled by Proxies / Load Balancers.

Doing this in Jira will slightly overhead the node on every request, but may still worth the tradeoff of blocking performance wrecking requests — just be cautious on writing too many rules and always test them in UAT and be ready to revert the changes should you suspect of underperformance after implementing them.

The information in this page relates to customizations in Jira. Consequently, Atlassian Support cannot guarantee to provide any support for the steps described on this page as customizations are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.

Also, please be aware that customizations done by directly modifying files are not included in the upgrade process. These modifications will need to be reapplied manually on the upgraded instance.

Environment

Any Data Center version of Jira Software or Jira Service Management that already has the urlrewrite.xml file.

Solution

Identifying the requests to block

The Tomcat Stuck Threads Valve can be used to spot the kind of requests taking longer than the defined threshold (we advise 120s as default).

Refer to How to read the Tomcat Stuck Threads log or StuckThreadDetectionValve in Jira for more on how to read the entries and how to configure the Log Valve in Tomcat.

This log parsing example (for Linux on "catalina.2024-03-04.log") will rank the requests showing up the most on the Stuck Thread log:

1 grep -a -h -E 'StuckThreadDetectionValve.notifyStuckThreadDetected' catalina.2024-03-05.log | grep -E -o 'for \[http.*\] and' | sed -E 's/(for \[|\] and)//g' | sed -E 's/[&?]_=[0-9]+$//g' | sed -E 's/&_=[0-9]+\]//g' | sort | uniq -c | sort -nr

It can be run on any catalina.yyyy-mm-dd.log or the catalina.out itself, all located in the /Jira-install-path/logs/ folder.

Sample output:

1 2 3 4 5 6 7 8 9 10 11 44 https://Jira-base-URL/rest/api/2/jql/autocompletedata/suggestions?fieldName=labels&fieldValue= 15 https://Jira-base-URL/rest/api/1.0/labels/suggest?customFieldId=10102&query= 6 https://Jira-base-URL/rest/api/2/jql/autocompletedata/suggestions?fieldName=External+ID&fieldValue= 3 https://Jira-base-URL/rest/api/1.0/labels/suggest?query= 3 https://Jira-base-URL/rest/api/1.0/labels/77888999/suggest?customFieldId=10102&query= 2 https://Jira-base-URL/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId=9999&selectedProjectKey=JIRA 2 https://Jira-base-URL/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId=99999&selectedProjectKey=CONFL 2 https://Jira-base-URL/rest/api/2/jql/autocompletedata/suggestions?fieldName=CI+Label&fieldValue= 2 https://Jira-base-URL/rest/api/2/jql/autocompletedata/suggestions?fieldName=Labels+B&fieldValue= 2 https://Jira-base-URL/rest/api/1.0/labels/11222333/suggest?customFieldId=10205&query=

Notice how the fieldValue and query parameters are empty on the top long-running requests — this indicates those requests are autocompleting on empty input, and are usually the requests we'd want to block.

Blocking the requests

Jira and Tomcat allow for a in-product URL block mechanism using the urlrewrite.xml.

On the /Jira-install-path/atlassian-jira/WEB-INF/urlrewrite.xml

Replace this line:

1 <urlrewrite>

By these:

1 2 <!-- WORKAROUNDS FOR JRASERVER-73769: required use-query-string="true" --> <urlrewrite use-query-string="true">

And add the rules after the existing <rule>...</rule> but still inside the <urlrewrite use-query-string="true">...</urlrewrite>:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 ... </rule> <!-- START OF WORKAROUNDS FOR JRASERVER-73769 --> <!-- You can view the rules through https://your-Jira-URL/rewrite-status --> <!-- See this Tuckey doc for more on rule writing: https://tuckey.org/urlrewrite/manual/4.0/index.html --> <rule> <name>Labels suggestion block</name> <note>Silences labels suggestion with too few inputted characters. Workaround for JRASERVER-73769.</note>        <from casesensitive="false">^/rest/api/1.0/labels(/[0-9]+)?/suggest\?.*query=&amp;</from> <set type="status">204</set> <to>null</to> </rule> <rule> <name>JQL Labels suggestion block</name> <note>Silences labels suggestion with too few inputted characters. Workaround for JRASERVER-73769.</note>        <from casesensitive="false">^/rest/api/2/jql/autocompletedata/suggestions\?fieldName=(labels.*|.*Label|External\+ID)&amp;fieldValue=&amp;</from> <set type="status">204</set> <to>null</to> </rule> <!-- END OF WORKAROUNDS FOR JRASERVER-73769 --> </urlrewrite>

These two rules are blocking:

  • Every request to all Label type fields with empty input in the label autocompletion (query=&...).

  • Every request to some Label fields in JQL searches with empty input (fieldValue=&...)

The first is triggered when users simply click to expand the Label dropdown without entering any character. The second is triggered on JQL autocompletion of Label fields.

Notice the regular expression on the second rule to match all fields "starting with label", "ending with label" and the "External ID" field. This is just a example and has to be tailored to your specific scenario. You may reach out to the Community for insights on writing regular expressions that match the criteria you need.

This external documentation may also be useful on writing these custom rules: https://tuckey.org/urlrewrite/manual/4.0/index.html

On this example, we're returning HTTP Status Code 204, which means "no content". In the Network tab of the Developer Tools (HAR file) you'll see the response 204:

(Auto-migrated image: description temporarily unavailable)

Jira needs to be restarted for the changes to take effect and this should be applied to all nodes in the cluster, as it's a local file modification.

Admins should remember to port these modifications over when upgrading or setting up new instances.

And again:

The information in this page relates to customizations in Jira. Consequently, Atlassian Support cannot guarantee to provide any support for the steps described on this page as customizations are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.

Also, please be aware that customizations done by directly modifying files are not included in the upgrade process. These modifications will need to be reapplied manually on the upgraded instance.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.