Explorateur de données Discourse

:discourse2: Summary Discourse Data Explorer allows you to make SQL queries against your live database, allowing for up-to-the-minute stats reporting.
:open_book: Install Guide This plugin is bundled with Discourse core. There is no need to install the plugin separately.

:information_source: If you’re looking for examples or support for any custom queries, you can find lots of topics in our #data-reporting category under the sql-query tag. If there’s not one to suit your particular needs, please feel free to create a new topic to ask the community for some help. :memo: Query Help

:discourse2: Hosted by us? This plugin is available on our Business and Enterprise plans. Data Explorer | Discourse - Civilized Discussion

After installing the plugin, head to /admin/plugins .

de1

Click on the “Settings” button, and turn on data explorer enabled, then return and reload the page.
There should now be a tab in the stacked nav called “ Data Explorer ”. Select it or head to /admin/plugins/discourse-data-explorer , then use the + , Import or Run buttons to get started.

Default queries

On a fresh install, the data explorer now ships with several queries that can help you draw insights from your forum’s activity. Open any query and click Run to try it out.

Here's what the stock queries look like.

Note: Default queries are picked up from this file: discourse-data-explorer/lib/discourse_data_explorer/queries.rb at main · discourse/discourse-data-explorer · GitHub

If you have an awesome query that you want everyone to have, make a PR just like this one.

Default queries cannot be edited, feel free to copy the sql and paste it into a new query if you’d like to modify them.

Writing queries

When you click any of the Edit buttons on a query view, or start a new Explorer Query, you are presented with a screen like the one below:

The top two boxes are the name and description of the query. The name is what you’re selecting in the dropdown box, and the description should be used for things like explaining what to put in the query parameters or to describe what data is being queried.

The left pane is where you write the SQL query. Minor syntax highlighting and checking is provided.

Automatically running queries

While you can always run a query by clicking the Run button, you can save time when loading a query by adding the run parameter to the URL.

For example: /admin/plugins/discourse-data-explorer/queries/123?run

When this parameter is added to the URL, the query will run as soon as you load the page, so you don’t need to click the Run button to see the results. This is especially helpful for queries you run frequently, allowing you to bookmark them or add them to your sidebar with the run parameter included for a one-click report.

Importing queries

For an example, let’s import one that I wrote. Download this file, then open the import dialog and select the file to be uploaded or paste the query in the text box. Click Import to save it and then click Run to see the results.

most-common-likers.dcquery (1).json (442 Bytes)

Looks like all of the Discourse developers like each other quite a bit :heart:

Searching for queries

If you’ve accumulated too many awesome queries, no problem! The search bar can help you filter through titles and descriptions.

Allow non-staff groups to run queries

You can add specific groups (including moderators) to a query to grant them access to it:

After saving, you can find it from the Groups page for that particular group on the Reports tab:

Click any query to open it and then the Run button to see the results. You can also bookmark group reports by clicking the Bookmark button.

Sharing queries with predefined parameters

If you have included user-defined parameters in your query, you can share a link to the query and include the parameters in the URL so they will be pre-filled when the page loads.

You must include parameters in the URL in this format params={"parameter_name":"value"}. Separate multiple parameters with commas. For example:

discourse.example.com/g/my-group/reports/6?params={"param1":"value1","param2":"value2"}

Couple with the run parameter mentioned above, you can share a report with predefined parameters that runs automatically when loaded.

Result limits and exporting queries

With large queries, you may notice that there is a limit on the number of rows that the Data Explorer will display. By default, the limit is set to 1000 rows. This is to prevent excessively large queries from slowing down or disrupting the performance of your Discourse instance.

If you want to bypass this limit, you have a few of options:

  1. Pagination: You can paginate your results. Instead of trying to return all results at once, you can write your query to return a specific range of results. You can then adjust this range to view different sections of your data. This won’t increase the limit, but it will allow you to view all your data in sections.
  2. Increase the limit: If you have access to the Discourse server and are comfortable making changes to Discourse settings, you can increase the limit. However, this should be done with caution. Increasing the limit can put a lot of load on your server if you’re not careful, especially if multiple users are running large queries at the same time.
  3. Download the Results: You also have the option to download the query results instead of viewing them directly in Discourse by clicking either the JSON or CSV button after running the query. Data downloaded from a query in JSON or CSV format will have a much higher results limit of 10,000 rows. For programmatic purposes, you want want to opt for the Json format, or if you’d like to work on the data in a spreadsheet application, the CSV format might be more convenient.

It’s generally a good idea to try and write more efficient queries, or to filter your data so that you’re only retrieving what you need, rather than trying to bypass the limit.

You can also export the SQL query itself in .JSON format by clicking the Export button. Queries that are exported using this method can then be imported into other Discourse sites, or used with third party applications.

Query plan

The “Include query plan” checkbox can be used for better understanding and optimizing your SQL queries.

When you check this box and run a query, Discourse will display the sequence of operations used to access data in the Discourse database. This can include operations like scans, joins, sorts, and other database actions. By examining the query plan, you can see exactly how the database is executing your query.

The Data Explorer tutorial series

We also have a dedicated sql-tutorial series about the Data Explorer! If you’re interested in learning more about writing SQL queries in Discourse, we highly recommend reading through the topics in this series:

Last edited by @MarkDoerr 2026-02-25T00:39:12Z

Last checked by @hugh 2025-09-03T00:45:21Z

Check documentPerform check on document:
120 « J'aime »
Data Explorer Tutorial - Part 1 - Writing Your First Query
Daily graph of user time online
Data Explorer Tutorial - Part 2 - Discourse SQL Basics
Formatting Data Explorer Table Results
Visual forum statistics
Extracting email addresses for a group
Visual map of users
Can I see in the statistics which post received the most likes
Tags: how can admin see who is following what tags?
How do I download a record of top posts or most clicked links?
Retrieving user information via REST API
Can staff be able to see real author of anonymous posts
How to search/filter untagged topics
Exporting all Topic titles and IDs?
External Data Analysis
Redesign of use profile
How to look up a user based on a user_id?
Can I make a plug-ins to view a certain group of people?
Scan IP matched accounts
How to measure active users?
Legal Tools Plugin
Can I access my Discourse forum database?
Create report for amount of interactions per user
CSV of all editeds post by moderator
Discourse view file update does not reflect in browser
Where to find User ID information
[Paid] Data explorer queries for ticketing system use case
Transactional Email Service (Open Source)
Direct connect to the Discourse Database
See what categories new users (& other trust levels) post in most
How can I extract the adminstrative records for a EU GDPR request?
Counting and reporting post views for commercial forum users (so we can charge them per-view)
Top user list public
How do I audit votes for fraudulent behavior
How do I get a list of all users from the API?
Tracking referrals? Encouraging users to invite others?
Display Data Explorer query results in WordPress (with TwigAnything)
Database's Data Model?
Filter or create statistics
How do I add users to a group?
Discourse disk space limits per user?
Masonry Image Gallery
Estimated timeline on a project?
Report on User Fields?
Dashboard - Segment number of Posts and Topics by team
Badge image missing issue
Traditional multi level hierarchy vs flat discourse hierarchy
Is there a Trust Level Permissions Table?
Deleting posts by banned users with < 3 posts?
Calculating "Top" topics in Discourse
Is there a way to Search by Posts with No Staff replies on it
How to use SQL to query discourse database
Specify user by external id
How to check the uniqueness of users in "hot link" badge?
Active users per day
Questions about moving an existing forum to Discourse
Get a user object by username or id javascript
Best Practices on reply-by-email
Most liked reply
Likes on a post
Group forum members based on topics viewed?
The metrics on dashboard, do they include activities from administrators?
Can I access Discourse forum Database to use for PowerBI reporting?
Is there a log of user visits?
Find posts "solved" in specific month
Anonymous User Groups
Any way to NOT send emails when a topic category is changed?
View/read by user or of user's posts?
After server migration the images in posts aren't downloadable anymore
Bug with [code]anything[/code] on a single line by itself
Logo is not appearing showing broken after upload
Configuring how users can create and send invites for others to join your community
Users reporting lots of 502 errors when attempting to post due to "max consecutive replies" check
Wildcard search
What would you like to see on your Discourse 2.0 Admin Dashboard?
TeamSpeak Usergroups Sync
Use tags to duplicate images?
Database Access required for our forum
Updated discourse and now site fails to display
Automatic badge expiration
Looking to switch from Vanilla, and have a few questions
Comment on a question instead of answering it
How to create custom reports
Deleted username but can not use that username in other user
Category Remains Muted after Category is available to Everyone
Can staff see who voters in anonymous polls?
Speak to a Discourse Data Analytic representative
How do I pull a report for a single community member?
Report Links to New Topics by Date?
Excluding Suspended, Silenced and Suspect Users When Exporting
Theme-Component v Plugin: What's the difference
Export topics to Excel
Is there a document introducing the database schema design?
Overview which trust level has which possibilities
Why are some users greyed out?
How to get reports for just a specific category?
How to get posts viewed by a user via APIs?
Reports for group message statistics
TimeStamp of Tag
How we put people in a category?
Is it possible to see the dates of all scheduled topics?
Topic Count Per User for Custom Date?
Searching for unassigned topics
Reports by Discourse
How to see all invites and invite tree?
How can I get the list of Discourse Topic IDs dynamically
How to edit sign up form?
Filter posts with images (gallery view)
Tracking unique contributors
New users who visited this month?
Making report on group membership?
Where to find post contents in the database
Searching All Messages as an Administrator
Are Staff and All Groups Included in Dashboard Reporting?
Deleted user with rails console u.delete -> email still "taken"
First Name, Last Name
User posts export as csv or text
User Messages Inbox Error 500
Description of fields returned by Discourse API
Failed to bootstrap due to out of memory killer
Inviting Feedback for Discourse Wiki ("Morphpedia")
What will happen to my forum if discourse suddenly stopped?
Why aren't warnings easily accessible like suspensions are?
Create a Data Explorer query using the API
Automate the syncing of Discourse queries to Google Sheets
Organization of community Data Explorer queries
Get total list of topics and their view counts from Discourse API
Working around the 10,000 result limit of data explorer?
Selecting the Quarter results in custom way
Create a Report on Profile data
Who marked Solution for Topic
Can you view a 'revised' post after it has been revised
More data from Admin reports
Regarding possibility to use Discourse as an alternative to JIRA or Zendesk
Retrieve latest posts by ID
More granular Discourse metrics?
Dump all conversations in a file and structured data
Login type report / list?
Special role to access dashboard
Best API for All First Posts in a Category
Data Explorer: Posts by Category (Including Subcategories)
Can the period stats use custom time frames to not be limited to only the most recent period?
Tracking who accepted which invite link
Advanced Search: Find posts having staff color
2021: The Year in Review
Filter topics not answered by Staff
Can I download a user database and sort by time viewed?
Category API request downloads all topics
User Data By Date Rage
Browse the Postgres database
How do I extract raw data from my discourse community site?
Some issues with searching (sorting, searching deleted posts and such)
How to Delete Uploaded Files?
How to show badges in the message list?
How to show badges in the message list?
How to find pageview data for a specific topic?
Badges for X Number of Solutions Created?
Permanent deletion bug
Adding SSO after many users already signed up -- how to migrate them?
How could I get voters from a poll?
Notifications from muted categories when mailing list mode is enabled
API: how to get joined at date in user summary
Edit a user preference for everyone or a subset of users
Create a Network chart of your forum - data visualization
Discourse Narrative Bot Data Explorer Queries :robot:
How do I get a report of total topics by subcategory for all subcategories please?
Plugin causing errors during rebuild
User field searching / reporting
Admin dashboard report reference guide
Comment, Question, & Discussion Level Agreement Voting - is there an extension?
How to find deleted posts
SQL query for last created users of the past 30 days
How can I see Survey Results or Responses
Is there a plugin for detecting forum access data?
How to show non-staff posts with zero replies
Viewing all published pages in a single site window
Accessing a user's chat activity
Configure Facebook login for Discourse
Admin Reporting & Analysis: Incremental Changes
Access to OpenID claims data?
How to calculate engagement rate for Discourse?
How to export more than the 10,000 limit?
`/admin/customize/permalinks` only shows ~100 permalinks
Can we delete all 'Automatically Bumped' msgs in one go?
User Status
Sort or Order post with combination of both (Replies + Activity)
Dynamically update available user field values during a profile fill in
Can I create a dashboard for a specific group inside the community?
Error during upgrading from Beta 3.1.x to latest
Must have plugins and components for Discourse?
Full IP access log
Available settings for global rate limits and throttling
How can I use GUI to access the postgresql db in docker
Data Explorer query for topics N+ days old, that are unsolved
Page Publishing
Tips for Exporting User Data
Identify private message interactions between users
View tag changes
Types of community & their characteristics
Discourse Chatbot :robot:
Run Data Explorer queries with the Discourse API
2023: The Year in Review
"Ensure ad-blockers are disabled and try reloading the page." when enabling Data Explorer
Exploring Discourse Data Explorer on my Sandbox
Order/Filter searched topics by latest update to First Post
Discourse Automation
API Filter users by emails, including secondary emails
How do I clear user warnings?
Exclude certain categories from the Trust Levels
Topic Ratings Plugin
Forum Data
Is it possible to view all staff notices?
Discourse Retort
Advice on archiving a site
Cleaning up uploads and purging uploads from S3
Content Audit : Report to pull Categories, Topics and Replies
Exporting all Forum Posts for Manual Upload into External LLMs?
discourse容器部署方式下,如何在外部连接到数据库,例如使用DBeaver连接
I'm attempting to merge user accounts
获取昨日点赞或者浏览量,前10的帖子
Populate Data Explorer params with URL params
AI sentiment and emotion analysis reports
Bulk Export of Raw Post Sources with Markup
Bundling more popular plugins with Discourse core
Setting up automated admin notice alerts
Listing event invitees with email addresses
More charting options for Data Explorer
Topics list filter feature
Migrate a phpBB3 forum to Discourse
Using Parameters in Data Explorer Queries
How to find how long a user has viewed a topic/who has posted new topics/country of users
Error trying to edit a post with an image in (NginX Proxy Manager?)
Restrict moderator access to only the stats panel on the admin dashboard?
How does auto-close topics work?
Poll: Export poll results in CSV for quiz creator?
Query to find out who marked the solution as solved
Possible to run a report for most posts within community?
Add an Admin subtab for Inactive users
Questions regarding Discourse features
How to query an email list of users that are not actived
Advice on a support forum
Shopify Integration
How do I see Facebook signups?
Creating and managing polls
Poll: Export poll results in CSV for quiz creator?
Discourse disk space limits per user?
Sorting all users by total posts?
SQL: The most N used words per user (speak their language!)
User Summary - Most Liked By user attributions are incorrect
Maximum Number of Search Results?
Get only top level posts in topic via discourse API
How to get all the deleted posts for a specific topic
Stats reports on a per-category basis?
Data analytics by complex networks and text mining
Error thrown when importing a query in Data Explorer
Zero search results searching private messages for specific keyword
A way to see full list of users granted with a certain badge?
Who messaged the most?
Who messaged the most?
How to open hyperlinks in a new tab
Run report of digest Unsubscribes
Need log the who downloaded attachments
Poll problem - exact vote numbers needed
Telegram Notifications Plugin (discourse-telegram-notifications)
Get last :heart: via API
Is it possible to keep the votes history of a poll?
How do I check a badge's status midway to it being awarded?
What plugins do you use - and why?
Export list of users based on date range
How to get all posts a user interacted with?
How can I email all recently active users?
Raw Function limited to 100

Bonjour ! :slight_smile:

J’ai donc demandé dans ce fil de discussion comment copier les liens de tous les sujets d’une requête de recherche. On m’a dirigé ici. J’ai donc demandé au responsable de notre forum si nous avions ce plugin installé, ce qui est le cas. Cependant, nous ne savons pas comment l’utiliser pour copier tous les liens d’une requête de recherche dans un fichier CSV à l’aide de ce plugin. Quelqu’un a-t-il déjà effectué cette action et pourrait nous indiquer la bonne direction ? :sweat_smile:

Notez que je suis un utilisateur régulier du forum, je n’ai pas de pouvoirs de staff. Cependant, je transmets cette information au responsable du site qui en a, et qui peut le faire pour moi. :slight_smile:

Merci d’avance !

Bonjour Preston !

Le plugin Data Explorer vous permet de créer des requêtes SQL.

Vous voulez en créer une nouvelle qui liste les sujets que vous recherchez.

Ensuite, lorsque vous exécutez la requête, vous verrez un bouton CSV pour exporter le résultat dans un fichier CSV.

J’espère que cela vous aidera !

Faites-nous savoir si vous avez besoin d’aide supplémentaire pour créer la requête !

3 « J'aime »

Merci ! Je vais transmettre : câlins :

3 messages ont été déplacées vers un nouveau sujet : Contourner la limite de 10 000 résultats de l’explorateur de données ?

Salut, j’ai une demande de fonctionnalité pour cet excellent plugin.

Certains des rapports que je crée à l’aide de l’Explorateur de données seraient très utiles à mon équipe si je pouvais les lister sur la page Rapports du tableau de bord (/admin/reports).

Serait-il possible d’ajouter une option à chaque requête de l’Explorateur de données pour qu’elle soit listée sur la page Rapports ? Merci.

Par exemple :

  • Lister cette requête personnalisée sur la page Rapports
3 « J'aime »

Merci pour cette fonctionnalité !

J’explore comment nous pourrions écrire des métriques personnalisées. Nous utilisons Discourse en parallèle avec Workadvent.re (un outil de collaboration A/V 2D basé sur des avatars).
J’exécute un script personnalisé pour enregistrer les activités dans une feuille Google via un webhook. Pour avoir toutes les choses centralisées dans notre outil principal (Discourse), ce serait formidable d’avoir ces données imprimées dans Discourse…
Des astuces ?!

1 « J'aime »

J’espérais vraiment qu’il existe un générateur de requêtes qui aiderait à écrire du SQL. Mon SQL est vieux et rouillé, et le taper à la main est source d’erreurs et prend du temps. Ce serait bien s’il y avait un moyen plus simple !

2 « J'aime »

Salut @davidgs, bienvenue sur Meta :wave: :slight_smile:

Avez-vous essayé d’utiliser un LLM comme ChatGPT ? Il a une compréhension raisonnable de Discourse et a été assez fiable lorsque j’avais également besoin de créer des requêtes d’exploration de données.

J’écris souvent mes invites comme “Écrire une requête d’exploration de données Discourse qui renvoie x,y,z à partir de a,b,c où…” et j’obtiens quelque chose d’assez raisonnable.

Dans le coin supérieur droit de cette page, vous pourriez également voir une petite icône de robot comme ci-dessous.
image

Si c’est le cas, vous pourriez également essayer le Bot d’aide IA qui est intégré à Meta.

2 « J'aime »

La plupart d’entre nous ne le voient pas. Mais il y a toujours ask.discourse.com

2 « J'aime »

Ouais, je ne me souvenais pas si c’était toujours juste une chose de niveau de confiance 3 ou pas. Bonne idée pour le site ask.discourse.com.

À titre d’exemple, j’ai tapé écrire une requête d'explorateur de données discourse qui renvoie une liste de tous les utilisateurs qui ont dit le mot « logiciel » dans la barre de saisie de ask.discourse.com et j’ai obtenu la requête suivante :

SELECT 
    p.user_id, 
    u.username,
    COUNT(p.id) AS post_count
FROM 
    posts p
JOIN 
    users u ON u.id = p.user_id
WHERE 
    p.raw ILIKE '%software%'
GROUP BY 
    p.user_id, u.username
ORDER BY 
    post_count DESC;

Assez raisonnable. Je peux aussi garantir qu’il effectue des requêtes beaucoup plus complexes que celle-ci.

2 « J'aime »

L’exportation des données de l’explorateur de données ne fonctionne plus avec les dernières mises à jour de Discourse et de l’explorateur de données que j’ai installées il y a environ deux heures. Les données elles-mêmes sont créées correctement mais ne peuvent plus être exportées.

Cliquer sur les boutons JSON ou CSV provoque juste un bref flash et rien d’autre ne se passe. Cela fonctionnait bien il y a environ deux semaines.

Dans la console du navigateur, je vois l’erreur suivante :
CSV :

Uncaught TypeError: this.args.query is undefined
    _downloadResult query-result.js:310
    downloadResultCsv query-result.js:287
    _triggerAction d-button.gjs:160
    Ember 12
    _triggerAction d-button.gjs:157
    click d-button.gjs:106

JSON :

Uncaught TypeError: this.args.query is undefined
    _downloadResult query-result.js:310
    downloadResultJson query-result.js:283
    _triggerAction d-button.gjs:160
    Ember 12
    _triggerAction d-button.gjs:157
    click d-button.gjs:106
1 « J'aime »

Merci pour le rapport de bug, @GuidoD !

J’ai fusionné un correctif pour ce problème plus tôt aujourd’hui, veuillez essayer de mettre à jour et confirmer que cela fonctionne pour vous. :slight_smile:

2 « J'aime »

merci pour la correction rapide.
Je peux confirmer que cela fonctionne à nouveau correctement.

1 « J'aime »

pour une petite quantité de données, l’exportation en JSON et CSV fonctionne correctement. Mais pour une plus grande quantité de données, l’exportation CSV fonctionne bien, mais l’exportation JSON renvoie une erreur 502 bad gateway sur nginx (probablement en raison d’un délai d’attente après 30 secondes, car la création du fichier JSON prend plus de 30 secondes).
Existe-t-il un moyen simple d’augmenter la valeur du délai d’attente de nginx ?

Si je réduis la période de la requête, le fichier CSV fait 12,9 Mo et le fichier JSON fait 645 Mo. Le fichier CSV total fait 13,5 Mo, donc seulement un peu plus gros, mais le fichier JSON n’est pas créé en raison de l’erreur nginx.

Ou peut-être que la création du fichier JSON échoue en raison de données étranges. La création du fichier JSON crée-t-elle un fichier journal ?

Les requêtes JSON s’exécutent avec une limite externe plus élevée par défaut par rapport aux requêtes CSV. Ajoutez une pagination personnalisée dans la requête pour vous assurer qu’elle se termine à temps.

1 « J'aime »

Est-il possible d’exécuter des instructions UPDATE à partir de l’Explorateur de données ?

J’essaie de faire une mise à jour massive d’une certaine table, mais j’obtiens cette erreur :

PG::FeatureNotSupported: ERROR:  WITH query "query" does not have a RETURNING clause
LINE 29:   ) SELECT * FROM query

Non, Data Explorer n’exécute que des transactions en lecture seule. (Si vous aviez mis à jour votre requête pour inclure une clause RETURNING, vous obtiendriez une erreur de transaction en lecture seule.)

Si vous auto-hébergez, utilisez l’un des guides « launcher enter », comme

Si vous avez déjà conçu votre mise à jour, vous pouvez utiliser psql discourse au lieu de rails c.

Si vous êtes sur un service hébergé, contactez le support pour qu’il exécute la modification.

1 « J'aime »

Merci pour la réponse. Cela a du sens. Nous utilisons un service hébergé, je vais donc contacter leur support.

Si je partage une requête SQL avec le groupe des modérateurs, comment les utilisateurs du groupe des modérateurs peuvent-ils exécuter la requête depuis leur compte ? Ils ne peuvent pas voir le plugin Data Explorer.