1. In Google API Console, search for Google Analytics and enable it
2. Create credential, pick service account key, pick project owner and use json key type. Google will download the JSON private key file to your computer
Sample JSON private key file
3. Add a new user to the Google Analytics Dashboard. When ask for email, use the client_email from the JSON file. Give the new user permission for read.
4. Build the JWT file for authentication. I use https://jwt.io
Algorithm : RS256
Payload Data, change iat to current epoch time, exp to 1 hour later, https://www.epochconverter.com/
5. Generate Signature
You should find two text boxes. Paste the private key in the JSON private key file into the private key box without the \n
It will say invalid signature because we didn't provide the public key, but all we need is the encoded signature.
6. Server to Server Authentication
Put the whole encoded signature from jwt.io in the assertion parameter.
Request
Response
7. Try to get some data from Google Analytics
You can find the ids from Google Analytics dashboard, admin->view settings (far right)->View ID (187243477)
Request
Response
8. The access token is good for one hour. After that, we need to start from step #4-6 again
Sunday, January 27, 2019
Thursday, January 3, 2019
Oracle Statistics History
Check the current retention value.
For alter this retention period to 90 days
For check the old record present in database (upto you restore the stats)
Check out the statistics history
Check out the differences
Restore the previous statistics for the whole database
Restore the previous statistics for a schema
Restore the previous statistics for a table
Flush the shared pool to see the new execute plan after restore
select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual;
For alter this retention period to 90 days
execute dbms_stats.alter_stats_history_retention(90);
For check the old record present in database (upto you restore the stats)
select dbms_stats.get_stats_history_availability from dual;
Check out the statistics history
SELECT owner, table_name, stats_update_time
FROM dba_tab_stats_history
WHERE owner='OWNER_APP'
AND table_name='ORDERS'
ORDER BY stats_update_time;
Check out the differences
select * from table(dbms_stats.diff_table_stats_in_history(
ownname => 'OWNER_APP',
tabname => 'ORDERS',
time1 => systimestamp,
time2 => systimestamp-30,
pctthreshold => 0));
Restore the previous statistics for the whole database
execute dbms_stats.restore_database_stats(sysdate-1);
Restore the previous statistics for a schema
execute dbms_stats.restore_schema_stats (ownname=>'OWNER_APP',AS_OF_TIMESTAMP=>sysdate-1);
Restore the previous statistics for a table
execute dbms_stats.restore_table_stats (ownname=>'OWNER_APP', tabname=>'ORDERS', AS_OF_TIMESTAMP=>sysdate-1);
Flush the shared pool to see the new execute plan after restore
alter system flush shared_pool
Subscribe to:
Posts (Atom)