heroku: TZ var not working after setting it to NY time - heroku

I'm setting heroku's timezone to America/New_York like so:.
heroku config:add TZ="America/New_York" -a my-app
For some reason, the server keeps showing the logs in UTC time. Shouldn't it show them in ET ?
Log example
2018-12-18T01:40:06.064765+00:00

Related

Heroku logs are flooded with the log-runtime-metrics

The set of logs below is appearing every 20 seconds on my heroku app log.
heroku[web.1]: source=web.1 dyno=heroku.... sample#load_avg_1m=0.00
heroku[web.1]: source=web.1 dyno=heroku.... sample#memory_total=18.06MB sample#memory_rss=17.37MB sample#memory_cache=0.69MB sample#memory_swap=0.00MB sample#memory_pgpgin=7511pages sample#memory_pgpgout=2888pages sample#memory_quota=512.00MB
I've found out these are Runtime metrics logs (https://devcenter.heroku.com/articles/log-runtime-metrics), not error logs.
I've tried these commands to disable this function but it didn't make any sense.
$ heroku labs:disable log-runtime-metrics
$ heroku restart
$ git commit --allow-empty -m "Force Heroku build."
$ git push heroku master
I also checked my heroku labs feature conditions by the command below.
$ heroku labs
It says log-runtime-metrics is not activated.
I completely don't have any idea for the cause of this behavior.

Changing format of Heroku CLI logs' timestamps

Currently, when you check you app's logs with Heroku CLI using heroku logs, the timestamp format is the following:
2018-03-07T08:07:27.683252+00:00 heroku[web.1]: - State changed from starting to up
which I find too detailed.
Is there any command for my Heroku app environment to set logger timestamp format?
I want to trim the suffix after seconds to make it look like this:
2018-03-07T08:07:27 heroku[web.1]: - State changed from starting to up
Just a side-note: this is not my python app's timestamp format but Heroku's one
No, this is not something you can do.
Using a log retention system (there are several add-ons doing so), you may be able to do so though.

Copy production database to staging heroku

How can I pull my production database to my staging server on heroku?
I have two remotes, production and staging.
From the documentation it appears that I want to run heroku pg:copy COBALT GREEN --app sushi but it isn't clear what all the arguments mean. How can I copy my production database to my staging database?
First use:
heroku pg:info -a your_production_app
to retrieve the name of the environment variable that has the URL of your production db, e.g HEROKU_POSTGRESQL_WHITE_URL.
Then:
heroku pg_info -a your_staging_app
to get the same for your staging app (e.g. DATABASE_URL).
Finally:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
Just to add a clarification to the #Yoni Rabinovitch's answer.
I do not have named database so I needed to replace name with DATABASE_URL instead. It is not much intuitive to duplicate DATABASE_URL, is it?
So instead of:
heroku pg:copy your_production_app::HEROKU_POSTGRESQL_WHITE_URL DATABASE_URL -a your_staging_app
I used
heroku pg:copy your_production_app::DATABASE_URL DATABASE_URL -a your_staging_app
Hope this might help somebody.

Heroku Server timezone and logs time

I'm trying to change Heroku server timezone.
I've followed the steps in Why does Heroku log using the server time rather than the Rails time zone?
Executing heroku config: TZ: Atlantic/Cape_Verde
Executing heroku run bash date: Wed Jan 23 11:24:52 CVT 2013
However heroku logs --tail still shows dates with my local timezone GMT
Am I missing something? Thanks guys:)
As of version 6.15.5-1f03166
heroku config:add TZ="America/New_York"
worked for me. Make sure you run the command after navigating to the application directory. For the correctness of timezone, check this wikipedia page.
For e.g. use
heroku config:add TZ="Asia/Kolkata"
to get logs in Indian Standard Time.
In case, you are not inside your project directory, Heroku-cli expects an extra flag :
heroku config:add TZ="Asia/Kolkata" --app appname
where appname is the app name present on your Heroku dashboard and not your project name.
NOTE: By default, updating timezone re-deploys your running application.
If you are using a Log Viewer like PaperTrail, then one additional setting is required :
PaperTrail > Settings > Profile > TimeZone > DropDown of selectable TimeZones
Timezone for Heroku logs cannot be changed and logs will remain in UTC even if you change the dyno timezone. Which is also not recommended, timezones are best handled within your application, and for logs, the log viewer can provide timzezone setting.
Heroku addons for logging - https://elements.heroku.com/addons#logging
Source: https://help.heroku.com/JZKJJ4NC/how-do-i-set-the-timezone-on-my-dyno

heroku DATABASE_URL

On heroku, how to get the whole value of DATABASE_URL ?
When I issue a
heroku config --app APP_NAME
I get several config parameters but the DATABASE_URL is not entirely visible
DATABASE_URL => postgres://ruhej...s.com/oeuhenchej
Any idea ?
$ heroku config --app APP_NAME
(The Heroku toolbelt has been updated since the question was asked; the command now shows the entire DATABASE_URL.)
$ heroku pg:credentials:url YOUR_DATABASE_NAME
Gives you all the informations needed (url, port, dbname, user, password):
Connection information for default credential.
Connection info string:
"dbname=xxxxxxxxxxxxxx host=yyyyyyyyyyyyyyyyyyyyyyyyyyy.amazonaws.com port=5432 user=zzzzzzzzzzzzzz password=************* sslmode=require"
Connection URL:
postgres://zzzzzzzzzzzzzz:*************#yyyyyyyyyyyyyyyyyyyyyyyyyyy.amazonaws.com:5432/xxxxxxxxxxxxxx
This may seem really basic but your heroku APP_NAME is app_name.heroku.com. You can find that by logging into heroku.com and looking in your account. In order to get your app config variables you simply type into the console:
heroku config --app APP_NAME
To get the full database URL, use config:get from the Heroku CLI;
heroku config:get DATABASE_URL -a my-app-name
To get PostgreSQL dump file from heroku :-
heroku pg:backups:capture
heroku pg:backups
it shows all the backups
heroku pg:backups:url BackupID

Resources