Get started with Atlassian Analytics
Learn how to add Atlassian Analytics to a site and understand what you need to query data and create charts.
To connect your PostgreSQL database to Atlassian Analytics, you’ll need to do the following:
Allow Atlassian IP addresses for outbound connections.
Create a PostgreSQL read-only user.
Complete the connection form in Atlassian Analytics.
By default, PostgreSQL restricts connections to hosts and networks included in the pg_bha.conf file. You’ll need to add a line for each of the Atlassian outbound IP addresses to this file to allow connectivity to your database. Get the list of Atlassian IP addresses for outbound connections.
For example, these are lines we would add so our read-only user called atlassian_read_only can connect to our database called mydatabase:
1
2
3
4
5
6
7
8
9
10
11
12
13
host mydatabase atlassian_read_only_user 13.52.5.96/28 md5
host mydatabase atlassian_read_only_user 13.236.8.224/28 md5
host mydatabase atlassian_read_only_user 13.236.8.224/28 md5
host mydatabase atlassian_read_only_user 18.136.214.96/28 md5
host mydatabase atlassian_read_only_user 18.234.32.224/28 md5
host mydatabase atlassian_read_only_user 18.246.31.224/28 md5
host mydatabase atlassian_read_only_user 52.215.192.224/28 md5
host mydatabase atlassian_read_only_user 104.192.136.240/28 md5
host mydatabase atlassian_read_only_user 104.192.137.240/28 md5
host mydatabase atlassian_read_only_user 104.192.138.240/28 md5
host mydatabase atlassian_read_only_user 104.192.140.240/28 md5
host mydatabase atlassian_read_only_user 185.166.143.240/28 md5
host mydatabase atlassian_read_only_user 185.166.142.240/28 md5
Refer to the PostgreSQL documentation for more details on how to modify the pg_hba.conf file.
You’ll also need to ensure that the listening_addresses in the postgresql.conf file is set to either '*' (all addresses) or includes all Atlassian IP addresses. For example: listen_addresses='13.52.5.96/28 13.236.8.224/28 18.136.214.96/28 18.184.99.224/28 18.234.32.224/28 18.246.31.224/28 52.215.192.224/28 104.192.136.240/28 104.192.137.240/28 104.192.138.240/28 104.192.140.240/28 104.192.142.240/28 104.192.143.240/28 185.166.143.240/28 185.166.142.240/28'
You may have to restart your PostgreSQL instance for changes to take effect.
This step isn’t required, but we highly recommend you create a specific read-only user that you’ll use to connect your PostgreSQL database to Atlassian Analytics.
There are two ways to create a PostgreSQL read-only user:
Using psql
Using pgAdmin
To create a read-only user using psql:
To create a read-only user using psql:
Open a new terminal window, where you’ll input a series of commands to create the user.
Connect to your PostgreSQL instance: sudo -u postgres psql
Select the database you want to connect to Atlassian Analytics: \c database_name;
Create a new role for your read-only user: CREATE ROLE atlassian_read_only_user LOGIN PASSWORD 'secure_password';
Grant the necessary privileges for the new user to connect to your database:
1
2
GRANT CONNECT ON DATABASE database_name TO atlassian_read_only_user;
GRANT USAGE ON SCHEMA public TO atlassian_read_only_user;
Generate the GRANT statements that will grant SELECT access to the new user: SELECT 'GRANT SELECT ON '||schema_name||'."'||table_name||'" TO atlassian_read_only_user;' FROM pg_tables WHERE schema_name IN ('public') ORDER BY schema_name, table_name;
Copy the GRANT statements generated by the command in Step 6 then paste them into your terminal window. To restrict access to a subset of tables, only run the GRANT statements for those tables.
Example GRANT statements:
1
2
3
4
5
6
7
8
9
10
11
GRANT SELECT ON public."album" TO atlassian_read_only_user;
GRANT SELECT ON public."artist" TO atlassian_read_only_user;
GRANT SELECT ON public."customer" TO atlassian_read_only_user;
GRANT SELECT ON public."employee" TO atlassian_read_only_user;
GRANT SELECT ON public."genre" TO atlassian_read_only_user;
GRANT SELECT ON public."invoice" TO atlassian_read_only_user;
GRANT SELECT ON public."invoiceline" TO atlassian_read_only_user;
GRANT SELECT ON public."mediatype" TO atlassian_read_only_user;
GRANT SELECT ON public."playlist" TO atlassian_read_only_user;
GRANT SELECT ON public."playlisttrack" TO atlassian_read_only_user;
GRANT SELECT ON public."track" TO atlassian_read_only_user;
Your new read-only user should now have the necessary permissions for Atlassian Analytics to connect to and query your database.
Instead of using psql, you can use pgAdmin to create your read-only user.
To create a read-only user using pgAdmin:
Connect to your PostgreSQL server instance using pgAdmin.
In the server tree, right-click Login/Group Roles > Create > Login/Group Role.
Give the group role a descriptive name then select Save. You don’t need to create a password for the group role yet. You’ll create a password for the login role in a later step.
In the server tree, expand Databases, right-click on the database you want to connect to Atlassian Analytics, then select Properties.
In the Security tab, add a privilege for the newly created group role.
Select the group role in the Grantee dropdown.
Select Connect under Privileges.
Select Save.
In the server tree, expand Databases > expand Schemas > right-click public > select Grant wizard.
In the Object selection step, select the tables you want to access, then select Next.
In the Privilege selection step:
Select the group role you created in the Grantee dropdown.
Check Select under Privileges.
Select Next.
Review the SQL statements that will be executed on the database, then select Finish to run the statements and complete the process.
Note: If your schema is not “public”, you’ll also need to grant USAGE permissions on the schema.
Next, create a login role. In the server tree, right-click Login/Group roles > Create > Login/Group role.
In the General tab, give the login role a descriptive name.
In the Definition tab, enter a secure password for the login role.
In the Membership tab, add the newly created group role from the previous steps to the Member of section, then select Save.
Your new read-only user should now have the necessary permissions for Atlassian Analytics to connect to and query your database. Use the credentials you created for the login role when you set up your PostgreSQL connection in Atlassian Analytics.
After creating a read-only database user and allowing our outbound IP addresses, you can complete the connection form in Atlassian Analytics to add your PostgreSQL database.
To add PostgreSQL to Atlassian Analytics:
Select Data from the global navigation.
Select Add data source > PostgreSQL.
Fill out the required fields of the connection form:
Hostname or IP - Where your database is hosted.
Port:- Default port number for PostgreSQL is 5432.
Username - Username of the PostgreSQL read-only user you created.
User password - Password of the PostgreSQL read-only user you created.
Database name - Name of your PostgreSQL database.
Schema - You must select at least one.
Atlassian Analytics will connect with your database to get your schema, then your data source will be ready to use.
Was this helpful?