The present disclosure describes thiazole and pyridine carboxamide derivatives of formula (I) or a pharmaceutically acceptable salt thereof, wherein: X is C or N; A, B and D are rings; the bond represents a normalized bond within the aromatic ring containing both an N and X, which formally is represented by a C=C bond when X is C and a single bond when X is N; ring A is of the formula (A-l) or (A-2): wherein El and E2 are rings; their compositions and methods of use. The compounds inhibit the activity of the Pim kinases and are useful in the treatment of diseases related to the activity of Pim kinases including, e.g., cancer and other diseases.