Find pages that use certain macros/plugins

Stephan Haslinger May 31, 2012

Hi,

does anyone know a nice way to search Confluence for pages that use a given macro?

This would help to see which plugins are widely used or who is using certain plugins.

We could use this information to contact the plugin users directly or to see which plugins are no longer required and could be removed.

Regards,

Stephan

11 answers

1 accepted

28 votes
Answer accepted
SarahA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 13, 2012

For people who don't have access to the database, here's how to do it in Confluence 4.0 and above:

http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/

In a nutshell: In a nutshell: Enter the following in the Confluence search box, assuming that your macro name is “x”:

macroName: x*

The above works in out-of-the-box Confluence (no plugins required). If you install a plugin, you can also search for specific parameters and parameter values. See http://ffeathers.wordpress.com/2012/09/04/how-to-search-for-macros-and-macro-parameters-in-confluence-4/

I hope this helps!

Cheers, Sarah

Andre van der Elst September 13, 2012

I tried that, but I always get this response: "Did you mean: mucronate:sql*"

when searching for macroName:sql* (tried with or without a space after : )

SarahA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 14, 2012

Hallo Andre

Which version of Confluence are you using? The "macroName" search field is available in Confluence 4.0 and later.

In Confluence 3.5 and earlier, you can enter the curly brackets and the macro name surrounded by double quotation marks, like this:

“{sql”

More details in this post: http://ffeathers.wordpress.com/2011/11/04/how-to-search-confluence-for-usage-of-a-macro/

Cheers, Sarah

Gavin Fowler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 24, 2012

I believe it's cace sensative i.e. it has to be "macroName: SearchString*"

Karie Kelly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2013

This worked perfectly for us! We had migrated to Confluence 5.0 (we were on OnDemand). The JIRA macro could not be converted correctly. This saved us a ton of time by locating the pages and making the updates manually -- we had started down the path of reviewing every page for the problem until we came across this. Thanks!!!!

Brian K September 18, 2014

yeah, this is great!

Jorge
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 28, 2014

Great answer Sarah. What if I can't fined the exact macro name to use in the search? For example we're using the Customware Visibility plugin. But when i search for 'macroName:show-if' the result is 0, and i know that it's used. Any tips?

Laura Witty February 2, 2016

It does show "did you mean.." etc, but it still presents the results for what you asked for.

Derek Broughton November 27, 2017

When I use that search, for either macroName:sql* or macroName:sql-query, I get exactly one result, even though I have dozens of pages using this macro. It only seems to find the outer macro, and almost all of my sql-query macros are wrapped in a run query.

Like Logan Hawkes likes this
Bernd Schneider November 6, 2018

Hm. For me it seems to work sometimes, sometimes not. I can also find macroName: excerpt-include*. But searching for the "Page properties" macro doesn't work. Can the blank in the macro name be the problem?

I tried:

macroName: page*
macroName: page properties
macroName: "Page properties"
...

I found pages, but that seems to be not connected to what I search.

Like Logan Hawkes likes this
Bernd Schneider August 24, 2023

I found out, how to get the macro names. If you want to find it you have to look at the page in storage format (... menu of the page). There you can see the real names by searching (Ctrl-f) for "ac:structured-macro ac:name".

Then you find that the page properties macro has the "intuitive" name "details".

Another successful Atlassian way to impede their users by hiding information. Of course none of them every will read these community issues and improve anything. They just sit and count their money.

11 votes
Jason Hensler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2012

I was using the usage macro in the confluence 4.0. it installs and runs but, has always been slow and causes the server to hang up while running. What we have since done is borrowed and tweaked the sql it was running, and run it directly against the sql server. The code will check in pages and blogpost where the content is the current version and not deleted. I will return a contentid, page title, the space id, the creator, and when it was modified. We use the following code:

Select CONTENT.CONTENTID, Title, SpaceID, CREATOR, LASTMODDATE
from CONTENT, BODYCONTENT
WHERE 
PREVVER IS NULL 
AND (CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST') 
AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID 
AND CONTENT_STATUS = 'current'
AND (BODY like '%{macro%')

Opps that code works for un converted macros in confluence 4.

For converted macros replace the last line with

AND (BODY like '%<ac:macro ac:name="MACRO">%')

You can go straight to a page by using this link and replacing CONTENTID with the returned contentid from the sql results https://confluence-install/pages/viewpage.action?pageId=CONTENTID

Jason Hensler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2012

Change "CONTENTID" to "CONTENT.CONTENTID"

Gavin Fowler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2012

works perfectly Jason - many thanks for the advice!

Select CONTENT.CONTENTID, CONTENT.Title, CONTENT.SpaceID, CREATOR, LASTMODDATE
from CONTENT, BODYCONTENT
WHERE
PREVVER IS NULL
AND (CONTENT.CONTENTTYPE = 'PAGE' OR CONTENT.CONTENTTYPE = 'BLOGPOST')
AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID
AND CONTENT.CONTENT_STATUS = 'current'
AND (BODYCONTENT.BODY like '%{cache%')

Gavin Fowler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2012

I'm running confluence 4.2.x and this works for me:

Select CONTENT.CONTENTID, CONTENT.Title, CONTENT.SpaceID, CREATOR, LASTMODDATE
from CONTENT, BODYCONTENT
WHERE
PREVVER IS NULL
AND (CONTENT.CONTENTTYPE = 'PAGE' OR CONTENT.CONTENTTYPE = 'BLOGPOST')
AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID
AND CONTENT.CONTENT_STATUS = 'current'
AND (BODYCONTENT.BODY like '%{cache%')

EDIT: Andre beat me to it :)

Andre van der Elst September 12, 2012

I tried running this (on mysql 5.0.95):

Select CONTENTID, Title, SpaceID, CREATOR, LASTMODDATE
from CONTENT, BODYCONTENT
WHERE
PREVVER IS NULL
AND (CONTENTTYPE = 'PAGE' OR CONTENTTYPE = 'BLOGPOST') 
AND CONTENT.CONTENTID = BODYCONTENT.CONTENTID 
AND CONTENT_STATUS = 'current'
AND (BODY like '%&lt;ac:macro ac:name="MACRO"&gt;%')

but then I get a 'ERROR 1052 (23000): Column 'CONTENTID' in field list is ambiguous' message from mysql.

Andre van der Elst September 12, 2012

FYI, this is on Confluence 4.3

John Price
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 18, 2013

Jason's SQL is the method to use when looking for a macro that is not working. For example, Graphviz recently became commercial and our existing pages using it now fail.

macroName:flowchart

does not work but the SQL method does. We needed it to answer the question: How many pages were using this plugin and should we buy it?

10 votes
GBE February 3, 2017

On recent version of confluence (5.10+), it seems there is the usage of each macro, grouped by plugin, listed on this admin page:
https://%confluence%/admin/pluginusage.action 

The SQL queries were good, but they also returned some false positive (ex. if the macro name is used as a parameter of another macro, you will get a match on this page).

Gilles

cf. https://confluence.atlassian.com/confkb/how-to-get-a-list-of-the-most-popular-macros-used-in-confluence-353764197.html

Lorenzo Babbage October 12, 2017

Very helpful!

A December 15, 2017

best answer for current versions

Ed Kershenbaum February 7, 2019

Thanks!  Works great in Cloud Confluence as well!

https://YourNameGoesHere.atlassian.net/wiki/admin/pluginusage.action

Like # people like this
Nilesh Raut May 15, 2019

Thanks! This is helpful.

Sugandha Sahay June 3, 2021

Saved me a ton of time, thanks!

Bernd Schneider June 6, 2021

But for us it is impossible that all have to become admins to see this. We need a possibility to find the used macros as normal users.

2 votes
Sandro Herrmann [Communardo]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2012

We wrote a little user macro for this requirement to create an overview page. Please use this macro only for Confluence version 3.5.x and older. Futhermore the performance of that macro iss very bad. Use is with care.

 

## @param macroname:title=Macro Name|type=string
 
#set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager=$getInstanceMethod.invoke(null,null))
#set($containerContext=$containerManager.containerContext)
   
## the pageManager gives you access to the pages
#set($pageManager =$containerContext.getComponent('pageManager')) 
 
## the spaceManager gives you access to the spaces
#set($spaceManager =$containerContext.getComponent('spaceManager')) 
#set($macroNameSplit = $parammacroname.split(",") ) 

#foreach( $space in $spaceManager.getAllSpaces() )   
 
    <ul>
    #foreach( $page in $pageManager.getPages( $space, true) )   
        #foreach( $macroName in $macroNameSplit )   
            #if( $page.content.contains("{$macroName" ) )
               <li><a href="$req.contextPath$page.urlPath">$space.key:$page.title  &rarr; $macroName</a></li>
            #end
        #end
    #end
    </ul>
#end

 

 

2 votes
hsuhailah
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2012

If you're using Confluence 3.5.x and earlier, you can try out Usage Stats Macro

Stephan Haslinger May 31, 2012

Hanis,

thank you for the fast answer. I am about to upgrade from 3.5.x (right now). I have saved the list :)

Is there any way to do that with Confluence 4.x?

Regards,

Stephan

Gavin Fowler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 12, 2012

I'd also be interested in how to do this in confluence 4.x installation - a number of macros/plug-in I've used in the past have gone commercial and I'm being asked how widely they are being used in order to justify the purchase. Any 4.x suggestions woudl be most welcome.

1 vote
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2013

Here's a macro that gets all macros used on all pages in a space. You can modify it to suit your needs (such as replacing the macroNames list with a single macro.

## Macro title: Macro Usage Report
## Developed by: Matthew J. Horn
## Date created: 11/12/13
## This macro takes no parameters
## @noparams

## Get a list of User Macros
#set($containerManagerClass = $content.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
#set($macroManager = $containerContext.getComponent('userMacroLibrary'))
#set($macroMetadataManager = $containerContext.getComponent('macroMetadataManager'))
#set($macroNames = $macroManager.getMacroNames())

## Get the ExcerptHelper (probably not supposed to be used for getting all macros, but it works)
#set($eHelper = $containerContext.getComponent('excerptHelper'))

## Get a list of pages in the space
#set ( $targetSpace = $spaceManager.getSpace("demo") )
#set ( $allPagesInSpace = $pageManager.getPages($targetSpace, true) )

## List all macro names
<h3>Macro names</h3>
<hr/>
#foreach($name in $macroNames)
  $name, 
#end

## Iterate over each page and check if each of the macros in macroNames is used on that page
<h3>Macro Usage</h3>
<hr/>
<table>
  <tr><th>Macro</th><th>Description</th><th>Page (isValid) (parameters)</th></tr>
  #foreach ($name in $macroNames) 
    <tr>
      <td>$macroMetadataManager.getMacroMetadataByName($name).getTitle().getKey() ($name)</td>
      <td>$macroMetadataManager.getMacroMetadataByName($name).getDescription().getKey()</td>
      <td>
      #foreach ($page in $allPagesInSpace)  ## $page is of type Page
        #if ($eHelper.getMacroDefinition($page, $name))
          <a href="$page.getUrlPath()">$page.getTitle()</a> ($eHelper.getMacroDefinition($page, $name).isValid()) ($eHelper.getMacroDefinition($page, $name).getParameters())<br/>          
        #end
      #end
      </td>
    </tr>
  #end
</table>

 

 

Nari Man
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2014

Matthew

How do I use this please?

Nari Man
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2014

I added this Macro to user Macros and then created a page with this macro added in. I still do not get the list of Macros used on the space. Any ideas? I am using COnfluence 5.1.1

David Hergert _PAYX_ February 16, 2016

This is nice, but it should be clear, this only is for user macros.

Luis April 27, 2021

// then name of the app from $macro.getPluginKey()

...

function lookPlugin(pluginkey){

var html = '';
var searchURL = '';
AJS.$('#queryStatus span').text('Buscando plugin: ' + pluginkey);

searchURL = AJS.params.baseUrl + '/rest/plugins/1.0/' + pluginkey + '-key';

var nombrePlugin= 'hola';

AJS.${d}.ajax(
{
type: 'GET',
url: searchURL,
async: false,
dataType: "json",
timeout:60000,
success: function(data) {

nombrePlugin=data.name + '(' + data.version+ ')';

},
error: function (x, y, z) {
nombrePlugin= 'Other:' +pluginkey;
}
}
);

return nombrePlugin;

}

1 vote
Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Using:

macroName: Table-of-Contents*

or any variation of this name/format doesn't find the TOC macro. It works perfectly well on single words, but not at all on multi-worded titles.

We're using 4.3.7. Cheers.

Karie Kelly
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

In the latest Confluence upgrades, you can no longer search macroName:JIRA Issues - it only locates those pages that have JIRA Issue

I submitted a support ticket and was told that this wasn't a bug as this was an unintended release of a feature. So, since it was not intended to be released, any issues are not bugs.

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2014

I've just tried this again in 5.4.3 Download and it still works in the way I've described above.

So: macroName: Code-Block* - doesn't find the macro (though it does find other things).

However: macroName: code* - finds all pages using the Code Block macro.

Cheers.

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2014

More info on this.

When I started searching it was from the global search field. However, I've also tried this in specific spaces AND in sets of sub-pages that use the Page Tree Search macro.

This means you can run the search on a very specific set of pages. HTHs.

Cheers.

0 votes
Pat Pigatti May 15, 2014

Hi,

Any idea when this will be supported again in a latest version of Confluence? Is there a feature request already on this? Thanks. Pat

Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2014

Pat,

See my comments above, are they helpful?

Cheers.

Pat Pigatti October 6, 2014

Hi Mikc, Kind of helps. Here's our scenario we are looking for a resolution or workaround if you know of one. If someone leaves the company, we'd like to be able to find references to them as used in macros such as the user-profile macro, so we can clean things up on pages. We have a work instruction for doing that, but the work instruction steps don't work anymore: we used to be able to do that with wiki markup but not in the new HTML5 format of Confluence. Any ideas? Thanks, Pat

0 votes
Mick Davidson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2013

Well that's not very helpful is it?

0 votes
Daniel Zimmerman May 27, 2013

Hello,

Most of these searches seem to be for searching the entire confluence wiki for a macro. What I would like is when editing a page, I would like to jump to the next instance of the macro while I am editing the page. Kind of like CTRL+F but instead of searching for text, search for a macro.

I have tried inserting macroName: Note* into the "Find" field when pressing CTRL+F but it did not seem to work. Any suggestions?

0 votes
Andre van der Elst September 12, 2012

bingo!

Gavin's query works!

Thanks to all for the help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events